zoukankan      html  css  js  c++  java
  • web.xml配置详解

    常用配置

      修改web应用默认首页

      <welcome-file-list>
        <welcome-file>index.html</welcome-file>//写首页的名称就行了
      </welcome-file-list>

      Servlet通配符映射及初始化参数

      

      <servlet>
          <servlet-name>patternServlet</servlet-name>
          <servlet-class>com.imooc.pattern.Employer</servlet-class>
      </servlet>
      <servlet-mapping>
          <servlet-name>patternServlet</servlet-name>
          <url-pattern>/employer/*</url-pattern>
      </servlet-mapping>
    
        String url = request.getRequestURI();
            System.out.println(url);    
            
            String employerId = url.substring(url.lastIndexOf("/")+1);
            
            System.out.println(employerId);
            
            if(employerId.equals("1")) {
                response.getWriter().println("wuyi");
            }

     

      全局配置

        

      <context-param>
          <param-name>content</param-name>
          <param-value>© 2020 imooc.com  京ICP备 12003892号-11</param-value>
      </context-param>
    
    ServletContext context    = request.getServletContext();
            
            String content = context.getInitParameter("content");
            
            context.setAttribute("content", content);
            context.setAttribute("title", "<h1>幕课网</h1>");
            
            response.setContentType("text/html;charset=utf-8");
            
            response.getWriter().println("ServletContext 学习");

         

     设置 404、500等状态码默认页面

      

      <!-- 指定错误页面 -->
      <error-page>
          <error-code>404</error-code>
          <location>/error/404.html</location>
      </error-page>
  • 相关阅读:
    js插件-图片椭圆轮播效果
    js-放大镜效果
    vue使用技巧,及遇到的问题
    vue的传参方式和router使用技巧
    关于new Date()的日期格式处理
    图片上传预览
    缓动动画的原理
    input不能输入汉字和负数
    上传格式判断方法
    Vue-cli3.0配置全局less
  • 原文地址:https://www.cnblogs.com/wuheng-123/p/13654314.html
Copyright © 2011-2022 走看看