【原创】java web strut…
2017-03-20 14:45
477 查看
刚学java EE,然后配置struts2 package 和include模块配置。
##########################struts.xml##########################
//struts.xml
class="cn.zhangzhipeng2023.struts2_test.action.LoginRegistProAction">
/WEB-INF/Content/index.jsp
/WEB-INF/Content/loginError.html
class="cn.zhangzhipeng2023.struts2_test.action.LoginRegistProAction"
method="registUser">
/WEB-INF/Content/index.jsp
/WEB-INF/Content/loginError.html
class="cn.zhangzhipeng2023.struts2_test.action.ViewUsersAction"
method="viewUsers">
/WEB-INF/Content/viewUsers.jsp
/WEB-INF/Content/loginError.html
WEB-INF/Content/{1}.jsp
WEB-INF/Content/{1}.html
##########################struts-admin.xml##########################
//struts-admin.xml
class="cn.zhangzhipeng2023.struts2_test.action.LoginRegistProAction">
/WEB-INF/Content/index.jsp
/WEB-INF/Content/loginError.html
WEB-INF/Content/{1}.jsp
WEB-INF/Content/{1}.html
##################################################################
访问:http://localhost:8081/struts2-test/admin/login
一直报404错误,因为我在web.xml 配置了error-code,所以一直是page no
found
于是将web.xml error-page节点注释掉,报了下面错误。看飘红字
type[/b] Status
report
message[/b] /struts2-test/admin/WEB-INF/Content/login.jsp
description[/b] The
requested resource is not available.
很明显,是配置出问题了,struts2配置中的namespace异常导致的,
struts.xml Action
WEB-INF/Content/{1}.jsp
这个WEB-INF前面是否指定根目录不重要,因为本身他就在根节点配置。
但是struts-admin.xml
这么配置就是错误的,运行结果就是/struts2-test/admin/WEB-INF/Content/***
当然找不到jsp文件了!!
所以在struts-admin.xmlAction中WEB-INF改成/WEB-INF
即可
#######################################################################
可以测试一下 http://localhost:8081/struts2-test/admin/login 正常访问了, http://localhost:8081/struts2-test/admin/test 就报错了
type[/b] Status
report
message[/b] /struts2-test/WEB-INF/Content/test.jsp
description[/b] The
requested resource is not available.
很明显,这个404是因为文件不存在,而不是路径不错在了。
##########################struts.xml##########################
//struts.xml
class="cn.zhangzhipeng2023.struts2_test.action.LoginRegistProAction">
/WEB-INF/Content/index.jsp
/WEB-INF/Content/loginError.html
class="cn.zhangzhipeng2023.struts2_test.action.LoginRegistProAction"
method="registUser">
/WEB-INF/Content/index.jsp
/WEB-INF/Content/loginError.html
class="cn.zhangzhipeng2023.struts2_test.action.ViewUsersAction"
method="viewUsers">
/WEB-INF/Content/viewUsers.jsp
/WEB-INF/Content/loginError.html
WEB-INF/Content/{1}.jsp
WEB-INF/Content/{1}.html
##########################struts-admin.xml##########################
//struts-admin.xml
class="cn.zhangzhipeng2023.struts2_test.action.LoginRegistProAction">
/WEB-INF/Content/index.jsp
/WEB-INF/Content/loginError.html
WEB-INF/Content/{1}.jsp
WEB-INF/Content/{1}.html
##################################################################
访问:http://localhost:8081/struts2-test/admin/login
一直报404错误,因为我在web.xml 配置了error-code,所以一直是page no
found
于是将web.xml error-page节点注释掉,报了下面错误。看飘红字
HTTP Status 404 - /struts2-test/admin/WEB-INF/Content/login.jsp
type[/b] Statusreport
message[/b] /struts2-test/admin/WEB-INF/Content/login.jsp
description[/b] The
requested resource is not available.
Apache Tomcat/7.0.55
很明显,是配置出问题了,struts2配置中的namespace异常导致的,struts.xml Action
WEB-INF/Content/{1}.jsp
这个WEB-INF前面是否指定根目录不重要,因为本身他就在根节点配置。
但是struts-admin.xml
这么配置就是错误的,运行结果就是/struts2-test/admin/WEB-INF/Content/***
当然找不到jsp文件了!!
所以在struts-admin.xmlAction中WEB-INF改成/WEB-INF
即可
#######################################################################
可以测试一下 http://localhost:8081/struts2-test/admin/login 正常访问了, http://localhost:8081/struts2-test/admin/test 就报错了
HTTP Status 404 - /struts2-test/WEB-INF/Content/test.jsp
type[/b] Statusreport
message[/b] /struts2-test/WEB-INF/Content/test.jsp
description[/b] The
requested resource is not available.
Apache Tomcat/7.0.55
很明显,这个404是因为文件不存在,而不是路径不错在了。
相关文章推荐
- 【原创】java web Actio…
- java web 乱码处理
- java web 获取路径
- java web开发之高并发处理
- Java web中cookies的用法
- Java Web应用下载文件以及下…
- Java Web总结(一)
- Web页面上工作流设计器(silverlight/Flex/Javascript/java Workflow&
- tomcat 中部署java web项目
- Java Web技术——JSP
- 【原创】Java HttpClient&nbs…
- 关于JAVA EE项目在WEB-INF目…
- java web工作中获得相应路径的方法
- Java Web应用开发中的一些概念
- Java Web项目中常用的工具类
- java WEB应用中的中文乱码问题初探
- java web项目用cookie记住用…
- 对于java web 项目中文乱码的解决…
- java web 笔试题
- 转载:C, Erlang, Java and Go Web…