一.Tomcat启动,控制台出现异常
Unable to load configuration
1.修改struts的配置文件时将一部分配置注释,注释的内容中还有其他注释符号导致配置文件出错,结果服务器启动报异常
2.action的配置部分找不着对应的action
3.action注解,在默认的跳转方式(请求跳转)下传参数
二.404错误
1.上面提到的struts配置文件错误会导致404
2.web.xml没有配置过滤器
<!-- 配置struts2过滤器 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
3.路径拼写错误
4.项目没部署到服务器
三.从action跳转页面导致bootstrap样式、图片出不来等问题
这是因为从action跳转到的页面相对路径加上了namespace,需要在页面设置相对路径:
方式1 el表达式: <base href="${pageContext.request.contextPath }/">
方式2 :<%String basePath=request.getContextPath()+"/";%>
<base href="<%=basePath %>">
或者使用绝对路径。
四.action页面重定向传参数中文乱码问题
保证编码一致性后
需要再跳转页面之前对要传的参数设置编码方式:
URLEncoder.encode("王五", "utf-8");