zoukankan      html  css  js  c++  java
  • servlet3.0 @WebServlet注解无效的情况

    web.xml文件中的metadata-comcomplete属性的作用:

      该属性指定当前的部署描述文件是否是完全的。如果设置为true,则容器在部署时只依赖部署描述文件,忽略所有的注解(同时也会跳过web-fragment.xml的扫描,亦即禁用可插性支持);如果设置为false或不配置该属性,则表示启用注解支持(和可插性支持)。

    注解有效的web.xml(metadata-complete="false"或者直接删除)

    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" 
        metadata-complete="false" version="3.1">
    
    </web-app>

    注解无效的web.xml(metadata-complete="true")

    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" 
        metadata-complete="true" version="3.1">
    
    </web-app>
  • 相关阅读:
    实时获取浏览器的窗口大小
    char*,wchar_t*,CString和BSTR之间的转换
    Struts2学习(五)
    Struts2学习(四)
    Struts2学习(三)
    Struts2学习(二)
    Struts2学习(一)
    Jsp学习(五)
    Jsp学习(四)
    Jsp学习(三)
  • 原文地址:https://www.cnblogs.com/guduershi/p/10170260.html
Copyright © 2011-2022 走看看