【原创】java web strut…

刚学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节点注释掉,报了下面错误。看飘红字

HTTP Status 404 - /struts2-test/admin/WEB-INF/Content/login.jsp


type Status report

message /struts2-test/admin/WEB-INF/Content/login.jsp

description 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 Status report

message /struts2-test/WEB-INF/Content/test.jsp

description The requested resource is not available.


Apache Tomcat/7.0.55

很明显,这个404是因为文件不存在,而不是路径不错在了。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值