今天第一次搭建struts2框架,遇到的问题还真多,按照struts的方法在系统添加了对sitemesh的支持
登录页面sitemesh正常工作,我本以为OK了,没想到登录成功后,转到index.jsp时,sitemesh竟然不工作了,我仔细的检查了几遍,问题依旧
无意间在网上看到说web.xml的struts2, sitemesh配置顺序应该是这样的
- ActionCleanUp
- sitemesh
- struts2
正常的web.xml
<!-- config ActionContextCleanUp filter -->
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- config sitemesh -->
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>
com.opensymphony.module.sitemesh.filter.PageFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- config struts2 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- config sitemesh tld -->
<jsp-config>
<taglib>
<taglib-uri>sitemesh-page</taglib-uri>
<taglib-location>
/WEB-INF/tld/sitemesh-page.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>sitemesh-decorator</taglib-uri>
<taglib-location>
/WEB-INF/tld/sitemesh-decorator.tld
</taglib-location>
</taglib>
</jsp-config>
<!-- config welcome page -->
<welcome-file-list>
<welcome-file>/form/login.jsp</welcome-file>
</welcome-file-list>
我原来的顺序:
- struts2
- sitemesh
看来struts2+spring2.5+hibernate3.2(增加对sitemesh, ajax的支持)的路还长着呢