web.xml 中 含义


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

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

在输入\时发挥作用,无论是根目录还是子目录!
(1)http://192.168.1.66:8080/ 在这种不指定文件的情况下就去访问welcom-file:welcome.jsp若存在,就显示出来,若没有,就接着向下找index.jsp,若都未找到,则显示空页面。
(2) 上面http://192.168.1.66:8080/ 是根目录,其实在子目录下也是如此,如在http://192.168.1.66:8080/news/
它就会去找news下的welcome.jsp, index.jsp文件,并显示。

ps: struts2.0 的一个技巧:让面对”\”时执行*.action,而不是页面
方法:
<welcome-file-list>
<welcome-file>index.action</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
(1)? 因在遇到”\’ 时读取 <welcome-file>,它必须已文件存在,故要在目录下建立一个名为index.action的空文件
(2)那么当遇到“\”时,因index.action存在,路径由:”\” 变化了 “\index.action” ,此时在此目录下对应的命名空间下
建立index.action即可。?
要点:在web.xml指定index.action为welcome-file , 在想让执行index.action的目录下建立一空的index.action文件
配置struts.xml,建立index.action