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文件作为配置文件。
分享到:
相关推荐
struts-config.xml struts标准配置文件 struts-config
Struts框架中struts-config.xml文件配置小结
struts-config.xml配置文件对学struts的人必备的查找资料。
struts-config.xml配置文件 struts-config.xml配置文件 struts-config.xml配置文件
struts-config.xml 详解struts-config.xml 详解
Struts-config.xml配置详解,介绍Struts-config中8个元素配置方法。
struts-config.xml配置文件详解
2.5.10.1.jar,struts2-config-browser-plugin-2.5.10.1.jar,struts2-convention-plugin-2.5.10.1.jar,struts2-dwr-plugin-2.5.10.1.jar,struts2-embeddedjsp-plugin-2.5.10.1.jar,struts2-gxp-plugin-2.5.10.1....
韩顺平视频配套struts-config.xml配置详解.txt
配置 struts-config.xml 元素 属性的详解!转载来的,,看着很好!》希望对大家有用!
这个strut-config配置详解是韩顺平老师指定的 很多同学都看过韩老师的视频或者上过韩老师的课程吧
SSH之Struts1之struts-config.xml常用配置详解(3-21-2008)
struts-config.xml 文件详解 以下是一份完整的struts-config.xml文件,配置元素的说明详见注释.
【Struts1.2总结】struts-config.xml配置
Struts-config.xml 配置详解.doc Struts-config.xml 配置详解.doc
Struts应用采用两个基于XML的配置文件来配置,分别是web.xml和struts-cofig.xml文件.web.xml文件是配置所有web应用的,而struts-config.xml文件是struts专用的配置文件。事实上也是可以根据需要给这个配置文件起其他...
struts--config.xml详解
struts-config1.1.xml