struts2 报403 错误
2017-01-13 16:30
281 查看
好久没有接触struts2了,今天在写一个简单的网页(jsp)的时候,在整合了struts2时发现一个问题。
详情:
jsp页面:index.jsp:输入用户名,登陆
login.jsp:登陆之后进入login页面:hello
struts2.xml:
<action name="login" class = "com.cyan.cloder.action.UserAction" method="addUser">
<result name="success">view/regist.jsp </result>
</action>
UserAction:
就一个execute:return SUCCESS;
启动就报了403的错误。HTTP Status 403 - Access to the requested resource has been denied
后来发现是因为web.xml的问题:
原web.xml:
<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>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<!-- Restricts access to pure JSP files - access available only via Struts action -->
<security-constraint>
<display-name>No direct JSP access</display-name>
<web-resource-collection>
<web-resource-name>No-JSP</web-resource-name>
<url-pattern>*.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>no-users</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<description>Don't assign users to this role</description>
<role-name>no-users</role-name>
</security-role>
更换的web.xml
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<!-- 让Struts 2的核心Filter拦截所有请求 -->
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
that's all get
详情:
jsp页面:index.jsp:输入用户名,登陆
login.jsp:登陆之后进入login页面:hello
struts2.xml:
<action name="login" class = "com.cyan.cloder.action.UserAction" method="addUser">
<result name="success">view/regist.jsp </result>
</action>
UserAction:
就一个execute:return SUCCESS;
启动就报了403的错误。HTTP Status 403 - Access to the requested resource has been denied
后来发现是因为web.xml的问题:
原web.xml:
<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>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<!-- Restricts access to pure JSP files - access available only via Struts action -->
<security-constraint>
<display-name>No direct JSP access</display-name>
<web-resource-collection>
<web-resource-name>No-JSP</web-resource-name>
<url-pattern>*.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>no-users</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<description>Don't assign users to this role</description>
<role-name>no-users</role-name>
</security-role>
更换的web.xml
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<!-- 让Struts 2的核心Filter拦截所有请求 -->
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
that's all get
相关文章推荐
- http协议的状态码——400,401,403,404,500,502,503,301,302等常见网页错误代码
- Struts2常见错误
- Apache访问index.html总是出现403 Forbidden错误的解决方案
- struts2文件上传与错误信息国际化
- nginx "403 Forbidden" 错误
- struts2校验器规范错误解决
- Struts2类型转换错误消息的显示
- ognl.OgnlContext cannot be cast to java.lang.String错误!可能的原因之一:jsp页面中包含和Struts2中的Context关键字重复从而产生冲突,修
- 在Struts2中使用poi进行excel操作下载的时候报getOutputStream() has already been called for this response 错误 [转]
- struts2常见错误总结
- 访问 Android Developers 403 错误
- struts2错误验证
- struts2学习(word文档备注不能正常显示,如有错误,忘不吝指正)
- windows Server2008 iis7 部署MVC4 项目的时候出现 403 错误
- S4.5_Struts2_ActionAdvance 使用action通配符捕获错误跳转到错误页面
- 各种让我崩溃过的struts2错误,包括与json ajax结合
- Apache服务器 403 Forbidden的几种错误原因小结!
- http协议的状态码——400,401,403,404,500,502,503,301,302等常见网页错误代码
- struts2校验问题!重复提交错误信息!
- django的403/404/500错误自定义页面的配置