web.xml和Struts-config.xml文件的区别
来源:互联网 发布:基建工程拍照软件 编辑:程序博客网 时间:2024/05/22 03:07
web.xml是配置给某个项目的,通常放在web-inf下面和classes同级.
一个Servlet应该去接受某个URL访问的请求,这个URL请求对应着哪一个SERVLET呢?
就在WEB.XML里面进行配置.web.xml(部署描述文件)
1、可以为你的Servlet注册和创建URL
2、注册和指定任何应用程序的过滤器filter和监听器listener
3、指定上下文初始参数的名/值对
4、可以进行配置错误页面
5、可以为应用程序指定欢迎文件
6、配置会话的超时时间
7、指定控制哪些人可以请求哪些WEB组件
struts-config.xml
这个东西算是在web.xml基础上面的一个扩展,struts只不过是apache组织为javaWeb应用创建的通用框架。
struts-config.xml主要是告诉Action接受了相关请求之后,根据相应的内容选择相应的动作:
1、接受某个URL请求之后,将请求转发到另外一个URL,或者另外一个ACTION
2、为Struts进行全局设置
3、定义数据源
4、处理Action抛出的特定的异常(以及全局异常)
5、定义Struts在启动的时候,或者关闭的时候进行加载或者卸载的插件。。plug-in 还有其他的功能。
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> </web-app>
看一下在使用了Struts框架的WEB.XML:
1、<url-pattern>*.do</url-pattern> :接受所有.do为结尾的URL请求 2、<servlet-name>action</servlet-name> :在WEB.XML中找到名字为action的Servlet的实现类 3、<servlet-class>org.apache.struts.action.ActionServlet</servlet-class> :找到了Struts的ActionServlet的实现类 4、<param-value>/WEB-INF/struts-config.xml</param-value> :这个Servlet在初始化的时候解析了Struts-config.xml文件作为配置文件。
- web.xml和Struts-config.xml文件的区别
- [java] struts的web.xml和struts-config.xml详解
- web.xml和struts-config.xml的配置
- web.xml和struts-config.xml的配置(ZT)
- web.xml和struts-config.xml的配置
- Struts1中web.xml和struts-config.xml的配置
- struts配置文件讲解:web.xml和struts-config.xml
- Struts中web.xml和struts-config.xml配置详解
- struts-config.xml文件
- struts-config.xml-context.xml-web.xml
- web.xml和struts-config.xml配置方法
- 关于Struts-config.xml文件的注意事项
- struts-config.xml的文件结构
- struts2.0 struts.xml和STRUTS的config.xml详解
- struts2.0 struts.xml和STRUTS的config.xml详解
- struts2.0 struts.xml和STRUTS的config.xml详解
- struts2.0 struts.xml和STRUTS的config.xml详解
- 关于struts.xml和struts-config.xml的误解
- memset
- 一个好用的变换类TransformManager
- 对话
- 发现一个可以免费自助建站的地方weebly
- 再次写给我们这些浮躁的程序员
- web.xml和Struts-config.xml文件的区别
- FreeBSD安装
- 第一博
- Linux 下串口编程入门 转载
- C#接口实例应用的的深入探讨
- 经典人生哲理
- 理想的计算机入门学习环境。
- What's the difference between Dictionary, Hashtable & Hashset?
- oracle中刪除重復的記錄,只剩一條