struts2默认结尾应该是.action
如果你是配置*.action
<filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping>
jsp中只要写 name.action就可以访问了。
如果你是配置*.do
<filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping>
必须在struts.xml中配置
<constant name="struts.action.extension" value="do" />
jsp中只要写 name.do就可以访问了。
如果你在struts.xml中配置
<constant name="struts.action.extension" value="do,action" />
jsp中只要写 name.do可以访问了。
jsp中只要写 name.action不能访问了。
如果你是配置/*
<filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
jsp中只要写 name就可以访问
jsp中只要写 name.action也可以访问
jsp中只要写 name.do不能访问
但是name.html之类的不能访问
如果你在struts.xml中配置
<constant name="struts.action.extension" value="do,action" />
jsp中只要写 name.do可以访问了。
jsp中只要写 name.action也可以访问了。
但是name.html之类的不能访问
配置/*.do或者/*.action
<filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*.do</url-pattern> </filter-mapping>
tomcat根本无法启动(这个不知道是怎么就出来了这种配置)
总结一下
struts.xml中应该有类似这样的配置
<constant name="struts.action.extension" value="action" />
如果我们不重写这个就会默认是action
如果我们重写这个配置
那么web.xml的拦截就必须是出现在value里面的某个值
struts2是灵活,灵活的让人崩溃。错误只是404,根本就不知道怎么出的问题。
/* 和 *.do的区别
具体不太了解,我的猜想是:
/*是rest风格的写法
*.do是传统写法
*.do有个优点是,拦截的数量比较少,比如css之类的都不会拦截
/*是不是需要根springmvc一样处理静态资源问题????