struts2核心配置之struts.xml
struts.xml
-常量配置
-包配置
-包含配置
一、常量配置
struts2常量的配置通常采用三种方式:
1、在struts.xml中使用<constant>元素配置常量
<struts>
<constant name="struts.i18n.encoding" value="UTF-8"></constant> <!-- 设置默认编码为utf-8 -->
<constant name="struts.devMode" value="true"></constant> <!-- 设置使用开发模式 -->
</struts>
2、在struts.properties文件中配置常量
3、在web.xml中通过<init-param>配置常量
二、包配置
Struts2框架的核心组件是Action和拦截器,它使用包来管理Action和拦截器,每个包就是多个Action,多个拦截器和引用的集合。
明白了package的地位,就跟我一起来学习学习,come
package常用属性
| 属性 | 说明 | 是否必须 |
| name | 指定该包的名字,唯一标识符,此名字是被其他包引用的key | 是 |
| namespace | 该包的命名空间 | 否 |
| extends | 继承其他包,可以继承其他包中的Action定义,拦截器定义 | 否 |
| abstract | 指定该包是否是一个抽象包 | 否 |
extends通常设置为struts-default,使该包中的Action具有Struts2框架中的默认拦截器等功能。
<package name="TestFirst" namespace="/" extends="struts-default">
<action name="FirstT" class="com.test.pojo.TestAction">
<result name="success">/success.jsp</result>
</action>
<action name="hello" class="com.test.pojo.TestAction" method="hello">
<result name="hello">/hello.jsp</result>
</action>
</package>
namespace设置为" / "或不写,访问Action路径为项目路径+actionName

namespace设置为” /* “,访问Action路径为i项目路径+” /* “+actionName

三、包含配置
<include>用来在struts.xml中包含其他配置文件

<include file="struts-HHH.xml"></include>
<include file="struts-KKK.xml"></include>
没一个被包含的配置文件都必须是标准的struts配置文件
struts2核心配置之struts.xml的更多相关文章
- Struts2系列笔记(2)---Struts.XML
Struts2.xml 本篇博客主要讲Struts2.xml中package下的标签和标签属性,主要分以下四个部分说明: (1)action的配置基本属性 (2)同一个Action类中不同方法满足不同 ...
- struts2简单入门-配置文件-struts.xml
struts.xml 作用:配置struts中的action,result,package,全局action,result,等等. 基本文件格式: <?xml version="1.0 ...
- struts2 一个简洁的struts.xml
struts.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUB ...
- struts2核心配置之Result
result作用:在struts.xml中,使用<result>元素配置result逻辑视图和物理视图之间的映射 元素属性 属性 说明 是否必须 name 指定逻辑视图的名称(Action ...
- 带拦截器配置的 struts.xml文件
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-/ ...
- struts2核心配置之Action
一.实现Action类 1.POJO实现(Plain Ordinary Java Object 简单的java对象) public class User1 { public String execut ...
- Struts2笔记1:--Struts2原理、优点、编程流程、6大配置文件以及核心配置文件struts.xml
Struts2原理(底层使用的是Servlet的doFilter方法): Struts2优点: 第一个Struts程序: 在开发Struts程序之前,首先要导入额外的jar包,基本需求的是14个jar ...
- struts2——配置struts.xml文件
在struts2框架中struts.xml是应当放到src的根目录,程序编译后会将struts.xml放到WEB-INF/classes目录下. Struts2在web.xml中的一般配置如下: &l ...
- Struts2第二篇【开发步骤、执行流程、struts.xml讲解、defalut-struts讲解】
前言 我们现在学习的是Struts2,其实Struts1和Struts2在技术上是没有很大的关联的.Struts2其实基于Web Work框架的,只不过它的推广没有Struts1好,因此就拿着Stru ...
随机推荐
- LeetCode--Remove Linked List Element
Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --& ...
- (转载)Java中如何遍历Map对象的4种方法
在Java中如何遍历Map对象 How to Iterate Over a Map in Java 在java中遍历Map有不少的方法.我们看一下最常用的方法及其优缺点. 既然java中的所有map都 ...
- [Leetcode] Path Sum路径和
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all ...
- 雪碧图background-position的rem用法
background的雪碧图配合rem就正常写即可,要加上background-size,大小为sprites的原图尺寸,宽高为一帧的尺寸.例如: .player{ width: 2.32rem; / ...
- bzoj进度条
好久没发进度了 这个月没有上个月那么猛,肯能使因为这个月不想水题吧 No. 510 Solved Problems List Solved 368 10001001100210071008101210 ...
- BZOJ 2500 幸福的道路(race) 树上直径+平衡树
structHeal { priority_queue<int> real; priority_queue<int> stack; void push(int x){ real ...
- [NOIP2016]换教室 期望dp
先弗洛伊德,然后把状态拆分遗传 #include<iostream> #include<cstdio> #include<cstring> #include< ...
- 怎么替换jar包里面的文件?
很多时候,我们需要替换包含在jar包里面的文件,例如修改里面的配置文件. 由于jar包已经生成,在不想重新用eclipse导出的情况下,我们怎么修改jar包里面的文件呢? 其实说出来很简单,可以使用以 ...
- Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) B
B. Little Artem and Grasshopper time limit per test 2 seconds memory limit per test 256 megabytes in ...
- HDU2389:Rain on your Parade(二分图最大匹配+HK算法)
Rain on your Parade Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 655350/165535 K (Java/Ot ...