DefaultAction

DefaultAction

正常情况下, 如果想访问某一个action, 需要在项目名后面+action的name值, 如下:

http://localhost:8080/struts2_011_DefaultAction/action的name值, 但是如果想直接输入

http://localhost:8080/struts2_011_DefaultAction/就能访问到页面, 就要设置defaultAction

配置之后当用户输入http://localhost:8080/struts2_011_DefaultAction/就能访问到设置的主页内容

另外, 用户可以在项目名后面随意加内容也会跳到主页, 原理就是如果找不到对应的action, 那么就会跳转到默认action

但是在WebRoot下不能有index.jsp, 否则找不到默认的页面, 会跳转到index.jsp, 即使在web.xml中去掉:

<!-- <welcome-file-list> -->
<!-- <welcome-file>index.jsp</welcome-file> -->
<!-- </welcome-file-list> -->

也会跳转到index.jsp, 所以不能有index.jsp, 或者把默认跳转的页面命名为index.jsp即可.

posted @ 2017-03-01 12:38  半生戎马,共话桑麻、  阅读(188)  评论(0)    收藏  举报
levels of contents