1.使用多个applicationContext配置文件避免配置文件混乱
可以使用通配符配置多个配置文件,然后在每个配置文件如下:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext.xml,
/WEB-INF/applicationContext-*.xml
</param-value>
</context-param>
2.struts在配置命名空间的时候,如果考虑不周直接跳转,可能会出现问题,还停留在前一级命名空间中,解决方法如下:
页面上有
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
然后
<base href="<%=basePath %>" target="_self" />
在使用struts标签的时候,指定命名空间
<s:url action="getUserInfo" namespace="/user"></s:url>
在使用html时,指定根目录
<a href="<%=path %>/blog/toBlogsIndex?globalCategoryId=0" id="all">

本文介绍了如何通过使用多个配置文件来组织Struts和Spring应用,避免配置文件过于复杂。具体包括如何配置通配符加载多个XML文件,以及在Struts中正确设置命名空间避免跳转错误的方法。
1407

被折叠的 条评论
为什么被折叠?



