关于url-pattern的编写方式和路径总结

1)关于url-pattern的编写方式和路径总结
       1.路径的编写方式:
           -
           -

            -重定向:response.sendRedirect("/项目名/资源路径")
            
           -转发:request.getRequestDispatcher("/资源路径").forward(request,response);
          
           -欢迎页面:
                    资源路径
                   

            -servlet路径
                   
                       hello
                       com.qq100910.LoginServlet
                   

                   
                        hello
                        /资源路径
                   

             cookie设置path
               -cookie.setPath("/项目名/资源路径");
            -ServletContext
               ServletContext application=config.getServletContext();
               application.getRealPath("/WEB-INF/calsses/db.properties");
               application.getRealPath("/资源路径")
    2.url-pattern编写方式:
       2.1 url-pattern 可以编写多个
       2.2 精确匹配
         /hello
          /system/hello
       2.3 扩展匹配
           /abc/*
       2.4 后缀匹配:
             *.action
              *.do
       2.5全部匹配
        *

你可能感兴趣的:(JAVAWEB)