zoukankan      html  css  js  c++  java
  • web.xml中的welcome-file-list标签作用

    welcome-file-list是一个配置在web.xml中的一个欢迎页,用于当用户在url中输入项目名称或者输入web容器url(如http://localhost:8080/)时直接跳转的页面.

    例如:

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

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

            <welcome-file>index.action</welcome-file>

    </welcome-file-list>

         welcome-file-list的工作原理是,按照welcome-file的.list一个一个去检查是否web目录下面存在这个文件,如果存在,继续下面的工作,先去webcontent(这里是Eclipse的工程目录根目录)下是否真的存在index.html这个文件,如果不存在去找是否存在index.jsp这个文件,以此类推。

          还要说的是welcome-file不一定是html或者jsp等文件,也可以是直接访问一个action。就像我上面配置的一样,但要注意的是,一定要在webcontent下面建立一个index.action的空文件,然后使用struts配置去跳转,不然web找不到index.action这个文件,会报404错误,原因就是我之前说的那样。

          如果配置了servlet的url-pattern是/*,那么访问localhost:8080/会匹配到该servlet上,而不是匹配welcome-file-list;如果url-pattern是/(该servlet为默认servlet),如果其他匹配模式都没有匹配到,则会匹配welcome-file-list。如果访问到了welcome-file,项目会自动跳转到欢迎页!

    /和 /* 对于所用请求都拦截,但是 / 对于 .jsp 的不拦截,直接访问到真实的jsp页面。

     

    <servlet>
      <servlet-name>hello</servlet-name>                  //起一个名字而已,与下面的servlet-mapping的名字一致,表示这两个是一组
      <servlet-class>com.briup.test.HelloWorld</servlet-class>      //拦截请求后调用这个类去处理
    </servlet>
    
    <servlet-mapping>
      <servlet-name>hello</servlet-name>
      <url-pattern>/world</url-pattern>                  //映射,拦截请求
    </servlet-mapping>

     

     

  • 相关阅读:
    Unable to locate package错误解决办法
    systemctl command not found
    create user, switch user
    Linux中“is not in the sudoers file”解决方法
    sed 修改文件中的行
    nvidia-cuda-toolkit install and uninstall nvidia-smi
    You can't access this shared folder because your organization's security policies block unauthenticated guest access. These policies help protect your PC
    ps auxf ps -ef ps -r cpu affinity
    message can not send, because channel is closed
    webMethods-Developer/Designer中try-catch与SQL中事务的实现
  • 原文地址:https://www.cnblogs.com/wskb/p/11526011.html
Copyright © 2011-2022 走看看