本文共 735 字,大约阅读时间需要 2 分钟。
1、首先需要明确的是struts过滤器配置映射的模式是路径匹配还是扩展匹配,如果url-pattern配置为/*,如果不做特殊处理,是不会转到welcome-file-list设置的文件的。 这种情况,有两种办法解决默认转向: a.一种是在struts.xml中定义一个默认的action,设置 <default-action-ref name="index"></default-action-ref> <action name="index"> <result type="dispatcher">login.jsp</result> </action> 这种方法推荐使用,不过有些特殊情况,比如不想把默认action配置在struts.xml中时候,就采取下面的方法。 b.一种是定义过滤器继承struts的过滤器,把上下文根路径排除,不让根路径请求转发到struts的过滤器中去,同时在web.xml定义默认的欢迎页。 欢迎页可以直接是Html或者jsp,在他们中可以定义跳转的action路径。 如: <meta http-equiv='refresh' content='0;url=login.jsp'> content中第一个参数为多少秒后跳转 否则会报 There is no Action mapped for namespace [/] and action name [] associated with context path [/MTMSWeb]. 2、第二种如果把url-pattern配置为 *.action ,在web.xml定义默认的欢迎页即可,但是所有的action请求的url都需要加上action后缀否则找不到action配置 转载地址:http://ylswn.baihongyu.com/