多目录配置后错误.跪求解答。
tomcat server.xml 配置项
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="ROOT" debug="0" />
<Context path="/test" docBase="/test" reloadable="true" debug="0" />
</Host>
java test 目录中
web.xml 配置项
XML code
<!-- Filter 映射 -->
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/test/*</url-pattern>
</filter-mapping>
<!-- struts2 -->
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/test/*.action</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>hibernateOpenSessionInViewFilter</filter-name>
<url-pattern>/test/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2CleanUpFilter</filter-name>
<url-pattern>/test/*.action</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2Filter</filter-name>
<url-pattern>/test/*.action</url-pattern>
</filter-mapping>
最后段 加入 /test/ 目录位置后,会启动不了 tomcat, 去掉 /test/ 后
文件会直接映射成 localhost:8080/prodoct.action?pid=1 , 而不是 localhost:8080/test/prodoct.action?pid=1
<filter-mapping>
<filter-name>struts2CleanUpFilter</filter-name>
<url-pattern>/test/*.action</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2Filter</filter-name>
<url-pattern>/test/*.action</url-pattern>
</filter-mapping>
跪求答案.. 谢谢帮忙
------解决方案--------------------
<url-pattern>/test/*.action</url-pattern>
这样写,只有符合/test/*.action的路径,才会被struts2处理。。直接打localhost:8080/prodoct.action是不会被struts2处理的。。