[struts]Write web.xml
来源:互联网 发布:理财收益计算器 软件 编辑:程序博客网 时间:2024/04/19 14:28
Because a Struts application is a Web application, it has to follow the same rules. that any Web application has to follow: Every Web application must have a web.xml configuration file. The web.xml file should define the ActionServlet, which functions as a controller from the standpoint of the MVC(Model - View - Controller)framework. In other words, every request to a Struts application has to go through the ActionServlet. the ActionServlet is provided by the Struts frameword.
The example web.xml file as shown below, has three different categories of configuration information:
- ActionServlet configuraton
- ActionServlet mapping
- Struts tag library descriptors
Under ActionServlet configuration section, note that several initialization parameters are specified as following through <init-param> elements:
- <param-name>application</param-name>
defines message resource file. it is set as following:
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param> - <param-name>config</param-name>
defines the path of the Struts configuration file. For example, the path of the Struts configuration file set to ./WEB-INF/struts-config.xml.
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml<param-value>
</init-param>
Under ActionServlet mapping configuration section shown below, it is set in the way that every request that has *.do URL pattern will be handled by the ActionServlet.
- <servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
Under Struts tag Library Descriptors configurations section, note three Struts tag libraries are configured.
A complete web.xml example:
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<display-name>Advanced J2EE Programming Class Sample App</display-name>
<!-- Standard Action Servlet Configuration (with debugging) -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
</web-app>
- [struts]Write web.xml
- struts标签库:bean:write web.xml
- [struts]Write struts-config.xml
- Struts首例:web.xml
- struts标签库:bean:write struts-config.xml
- struts-config.xml-context.xml-web.xml
- How to write XML Web Service
- struts-config,web.xml配置
- 【struts】web.xml的配置
- 转 struts web.xml配置
- struts web.xml简单配置
- web.xml之配置Struts
- Struts工程web.xml配置
- Struts简易计算器:web.xml
- Struts配置文件之web.xml
- struts-config.xml , web.xml配置示例
- web.xml 和struts.xml配置
- struts2 配置web.xml struts.xml
- 为了找一个好工作,得学习以下内容
- MySQL 命令集
- VC编译多个相关Project方法点滴(再续)
- 面向对象语言的Coercion Rules(强制原则)-杨大川老师设计模式课程总结
- 当项目灾难来临时该怎么办
- [struts]Write web.xml
- Forms身份验证基于角色的授权
- ASP.NET Session详解
- minisip with OpenSER in TLS
- Dhtml中DIV布局定位的直观图
- Scott Mitchell 的ASP.NET 2.0数据教程之三十二:: 数据控件的嵌套
- qeqerq
- DataGrid 或 DataView 中进行删除操作时间提示操作员确认
- string类型转化为数字类型