Servlet 3.0 使用注解配置URl提示404错误
我的环境是 Eclipse oxygen + Servlet 3.0
因为3.0已经开始使用注解了
之前我都是配置listenner 还有Servlet mapping 在 web.xml 中
就像 这样子

在xml中配置

现在 有了 注解 我们只需要在对应的 类上 写上 他的标签即可


就像 上图 所示
需要注意 的 一点是
matadata-complete 必须设置为false
Attribute : metadata-complete
The metadata-complete attribute defines whether this deployment descriptor and other
related deployment descriptors for this module (e.g., web service descriptors) are complete, or
whether the class files available to this module and packaged with this application should be
examined for annotations that specify deployment information. If metadata-complete is set to
"true", the deployment tool must ignore any annotations that specify deployment information,
which might be present in the class files of the application. If metadata-complete is not
specified or is set to "false", the deployment tool must examine the class files of the application
for annotations, as specified by the specifications.
Data Type : boolean
Enumerated Values :
- true
- false
可以 看到 true 的话 会 忽略注解 false 的 才会使用注解

Servlet 3.0 使用注解配置URl提示404错误的更多相关文章
- Servlet使用注解配置URl提示404错误
刚接触servlet 3.0,使用注释描述servlet @WebServlet(name="FirstServlet", urlPatterns="/FirstServ ...
- c# webapi发布到windows server 2008 r2 iis上提示404错误
项目服务端是一组RestFul风格的webapi,发布到本机的iis没有问题,但是发布到服务器以后就提示404错误.本机是win10的,服务器是windows server 2008 R2 64位.之 ...
- tomcat + jenkins启动tomcat后打开jenkins页面提示404错误的解决方案
首先下载tomcat和jenkins,将下载的jenkins2.12 war放到tomcat的webapps文件夹下后执行/bin文件夹下的start启动后,打开http://localhost:80 ...
- iis7 部署 mvc4项目提示404错误
1.装了.net framework 4.0框架 2.重新注册了asp.net_iisreg -i 访问mvc项目仍提示404错误 搜了一下,有些服务器还要装个补丁 https://support.m ...
- 在使用webstorm打开本地项目文件夹的html文件时,浏览器提示404错误
错误原因:在使用webstorm打开本地项目文件夹的html文件时,浏览器提示404错误. 错误分析:文件夹命名内包含“+”,此特殊符号导致浏览器解析错误. 改正方案:去掉特殊符号“+”
- Servlet --启动时创建、配置url、ServlectContext、初始化参数、获取资源
servlet的版本的区别 2.5版本, Servlet的配置只支持在xml文件中的配置 3.0版本: Servlet的配置支持在xml文件中的配置, 也可以使用注解的方式, 默认使用注解 让服务器在 ...
- Servlet生命周期和注解配置
Servlet的生命周期和注解配置问题 /* Servlet? 运行在服务器上的小程序 定义浏览器访问到Tomcat的规则 一.生命周期? 1.创建 2.提供服务 3.被销毁 二.servlet3.0 ...
- Servlet(二)----注解配置
## Servlet3.0 * 好处: * 支持注解配置.可以不需要web.xml了. * 步骤: 1.创建JavaEE项目,选择Servlet的版本3.0以上,可以不创建web.xml 2. ...
- 【Javaweb】Servlet的xml和注解配置
1.xml <%@ page language="java" contentType="text/html;" %> <!DOCTYPE ht ...
随机推荐
- 【JSP 标签】选择判断c:choose
在JSP页面中对 根据一个属性的多个可能的值进行相应的输出 <%@ page language="java" contentType="text/html; cha ...
- HashMap 数组应用面试题(Point)
今天看了一题面试题,以为很简单,不过自己写了遍,没有完全写出来: 题目是这样的: 给定一些 points 和一个 origin,从 points 中找到 k 个离 origin 最近的点.按照距离由小 ...
- Java:用Lambda表达式简化代码一例
之前,调用第3方服务,每个方法都差不多“长”这样, 写起来啰嗦, 改起来麻烦, 还容易改漏. public void authorizeRoleToUser(Long userId, List< ...
- Serializable序列化的作用
这里转载一篇讲解java序列化(Serializable)和反序列化方面的感觉很好的文章.1.序列化是干什么的?简单说就是为了保存在内存中的各种对象的状态(也就是实例变量,不是方法),并且可以把保存的 ...
- 对于c语言存储分配程序(malloc函数)实现的理解
内容主要出自<The C Programming Language>一书,不得不说这是一本程序员必读的书,我大二读了前面几章就扔到一边了,直到最近才又拿起来再读,找不到言语来形容我现在后悔 ...
- 后台方庄List razor 循环
后台: //1.查询所有年卡类型 StringBuilder sqlStr = new StringBuilder(); sqlStr.Ap ...
- Java代理详解
一.概述 代理模式是Java常用的设计模式之一,实现代理模式要求代理类和委托类(被代理的类)具有相同的方法(提供相同的服务),代理类对象自身并不实现真正的核心逻辑,而是通过调用委托类对象的相关方法来处 ...
- MySQL在高版本需要指明是否进行SSL连接问题
Java使用mysql-jdbc连接MySQL出现如下警告: Establishing SSL connection without server's identity verification is ...
- springboot配置swagger2
.在pom.xml里添加jar包: <dependency> <groupId>io.springfox</groupId> <artifactId>s ...
- 团队作业4——第一次项目冲刺(Alpha版本)2017.4.22
昨天来不及编写,这是4月22日的日志,现在补上. 1.开完站立式会议后的合照 2.任务分解图 3.开会讨论的结果,任务分派 队员 今日进展 明日安排 陈鑫龙 原型设计图分析,设计登陆界面原稿 实现登陆 ...