关于servlet开发时,web.xml的配置问题。
来源:互联网 发布:美工课教案 编辑:程序博客网 时间:2024/05/17 04:08
最近在学习servlet开发,做了几个示例,发现每写一个Servlet就要在web.xml对其进行配置,于是就在网上搜了一下,总结了几条。好记性不如烂笔头,今天做个记录。
本文参考来自http://zhidao.baidu.com/link?url=Fo6L8jzP6VuJUmy7d6XWU81RTWTvs1lpDajmFSREgh_YtwCLD_b9AZhoeK-BY8b9sQNwDZJg9FSSWGFmlOaih_
servlet 3.0 之前,确实要一一对应写到配置文件的。在servlet 3.0之后,使用注解形式就可以了。
例如:
@WebServlet(urlPatterns = {"/simple"}, asyncSupported = true, loadOnStartup = -1, name = "SimpleServlet", displayName = "ss", initParams = {@WebInitParam(name = "username", value = "tom")} ) public class SimpleServlet extends HttpServlet{ … }
除了注解之外还有三种方法可用:
⑴自己写个过滤器,拦截servlet请求并处理。
⑵用jsp也可以,不过,是jsp来写和请求了,jsp和servlet等价,jsp开发效率要高些。
⑶用拦截器框架,像Struts、SpringMVC、nutz都有这样的功能。
0 0
- 关于servlet开发时,web.xml的配置问题。
- web.xml中关于Servlet、Filter、Listener的配置 顺序问题
- JSP学习笔记之三——关于servlet配置web.xml出现的问题
- web.xml关于servlet配置中url-pattern的说明
- web.xml中关于Servlet、Filter、Listener的配置
- web.xml中关于Servlet、Filter、Listener的配置
- web.xml中关于Servlet、Filter、Listener的配置
- servlet的web.xml配置
- servlet的web.xml配置
- Servlet的web.xml配置
- spring关于web开发时xml文件的配置疑惑
- 关于servlet中web.xml的一些问题
- 告别jsp+servlet开发中,配置web.xml的烦恼
- Servlet 中 web.xml 文件的配置问题
- Servlet 中 web.xml 文件的配置问题
- Servlet中web.xml 配置问题,求解!!!
- Servlet开发技术,创建,以及Servlet的配置,web.xml的配置
- Spring Mvc 配置web.xml中的servlet-mapping时遇到的问题
- 剑指offer系列之五十:构建乘积数组
- 关于CRC校验进行完整性检查实现
- SVN:使用命令行模式访问SVN服务器
- 积跬步,聚小流------关闭iphone浏览器自动识别数字为电话号码
- 详细解析mtk android5.1(mt6580/mt8321)的display system
- 关于servlet开发时,web.xml的配置问题。
- 秒杀多线程第五篇 经典线程同步 关键段CS
- Android性能中容易忽视的优化点有哪些?
- c++智能指针:boost::scoped_ptr,boost::shared_ptr,boost::scoped_array
- 秒杀多线程第六篇 经典线程同步 事件Event
- JAVA关于HashMap浅谈
- 将apache添加至windows服务
- springAOP事物管理不生效原因总结
- SVN:版本库管理