Struts2关于struts.xml文件配置说明
来源:互联网 发布:微商城 源码下载 编辑:程序博客网 时间:2024/05/19 03:28
struts.xml是Struts2的核心配置文件,里面定义了请求与映射的关系。
package说明:
package的功能是用来管理action,一般可以按照模块功能划分。
<package name="helloworld" namespace="/" extends="struts-default"><action name="helloWorldAction" class="cn.itcast.HelloWorld.HelloWorldAction"><result name="index">index.jsp</result></action></package>name为包的名称,且值唯一。
extends实际是把package名称为struts-default包的功能继承过来。
namaspace说明:
1.如果namaspace为"/"
那么在请求URL时项目名称后面紧跟着action中name名称;
http://localhost:8080/项目名称/helloworld.action
2.如果namaspace为“/base”
那么在请求URL时项目名称后面紧跟着/baser然后是action;
http://localhosr:8080/项目名称/base/helloworld.action
如果请求为http://localhosr:8080/项目名称/base/a/helloworld.action也可以请求到,查找规则为:
先查找/base/a下的helloworld.action
如果没有,再查找/base下的helloworld.action
3.在URL中加了几层命名空间,则在转向jsp页面时,jsp的路径也会加几个命名空间名字的路径:
/base/helloworld.action
/base/index.jsp
在命名空间中有什么名称,在webroot下就应该建立什么样的文件夹。
____________________________________________________________________________________________
结果集说明:
步骤:
1.action类中方法必须返回一个字符串;
2.返回的字符串要和struts.xml文件中result标签的name属性一致
result两个重要的属性:
name:和action返回值对应 可以省略 默认值为success
type: 为结果集类型 可以省略 默认为转发
——————————————————————————————————————————————————————
include标签:
<struts><include file="struts-helloworld.xml"></include></struts>在大型项目中可以确保人手一份xml文件,这样不会出现冲突问题
____________________________________________________________________________________________
关于strurt.xml和strut-default.xml的说明:
1.这两个配置文件都是在服务器启动的时候加载的;
2.这两个配置文件都是放在classpath根目录下;
struts.xml在src根目录下
struts-default.xml在struts核心包的根目录下
3.struts.xml供程序员使用
struts-default.xml是运行在struts底层的xml文件
4.先加载struts-default.xml文件,再加载struts.xml文件
5.因为dtd一样,如果出现相同的元素,后者会覆盖前者。
- Struts2关于struts.xml文件配置说明
- Struts2配置struts.xml文件
- struts2 struts.xml文件<constant>标签说明
- struts2 struts.xml文件<constant>标签说明
- struts2 struts.xml文件<constant>标签说明
- struts2 struts.xml文件<constant>标签说明
- struts.xml文件的配置说明
- Struts2 Chapter2 struts.xml文件的配置
- struts2配置 struts.xml文件范例
- struts2 struts.xml配置中常见配置选项及说明
- struts.xml配置说明
- struts2 struts.xml配置
- Struts2-配置struts.xml
- Struts2 Struts.xml DTD 说明
- Struts2 Struts.xml DTD 说明
- struts2中web.xml配置struts.xml文件
- 关于Struts2中struts.xml文件分层问题
- Struts2 文件下载Action及Struts.xml配置
- Android-多线程下载
- MBProgressHUD项目能实现多种样式的提示框
- 基于RTP协议的H.264传输
- 内存分析工具 MAT 的使用
- myBatis-小提示
- Struts2关于struts.xml文件配置说明
- 1.1 从C到C++,C语言与C++的关系
- VC定时器的用法:SetTimer和Ontimer
- 浅析Android中的消息机制
- 从数据库层面理解:随机 I/O & 顺序 I/O
- UIView的autoresizingMask属性
- 检测当前进程是否存在硬件断点
- 有道云笔记、印象笔记、为知笔记、麦库记事国内四大笔记软件全方面比较
- 小P 的牧场(pasture)题解