Struts2学习五----------指定多个配置文件
© 版权声明:本文为博主原创文章,转载请注明出处
指定多个配置文件
- 在Struts2配置文件中使用include可指定多个配置文件
实例
1.项目结构

2.pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.struts</groupId>
<artifactId>Struts2-MultipleProfiles</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Struts2-MultipleProfiles Maven Webapp</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<struts.version>2.5.10</struts.version>
</properties> <dependencies>
<!-- junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- struts2 -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts.version}</version>
</dependency>
</dependencies> <build>
<finalName>Struts2-MultipleProfiles</finalName>
</build> </project>
3.web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0" metadata-complete="true"> <filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> </web-app>
4.HelloAction.java
package org.struts.action;
import com.opensymphony.xwork2.ActionSupport;
public class HelloAction extends ActionSupport {
private static final long serialVersionUID = 1L;
@Override
public String execute() throws Exception {
return SUCCESS;
}
}
5.struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts> <include file="helloworld.xml"/> </struts>
6.helloworld.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts> <package name="hello" extends="struts-default" namespace="/">
<action name="hello" class="org.struts.action.HelloAction">
<result>/index.jsp</result>
</action>
</package> </struts>
7.index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>指定多个配置文件测试</title>
</head>
<body>
指定多个配置文件测试成功
</body>
</html>
8.效果预览

参考:http://www.imooc.com/video/9000
Struts2学习五----------指定多个配置文件的更多相关文章
- Struts2 学习记录-1--Struts2中的配置文件
目录 1. web.xml 2. struts.xml 3. struts.properties文件 4.注解式开发 5.与Spring框架集成的配置 主要涉及3个配置文件:web.xml.strut ...
- 《struts2》:指定多个配置文件和默认Action
转载:http://m.blog.csdn.net/article/details?id=51212968
- Struts2学习笔记:DMI,多个配置文件,默认Action,后缀
动态方法调用有三种方法: 1.同一Action多次映射,每个action标签的method对应要调用的方法. 当要调用的方法多了就会增加struts.xml文件的复杂性. 2.struts.Dynam ...
- Struts2学习笔记(三)——Action详解
Action是用于处理请求操作的,它是由StrutsPrepareAndExceuteFilter分发过来的. 1.Action的创建方式 1) POJO类(PlainOldJavaObjects简单 ...
- Struts2学习笔记整理(一)
最近在学习框架,很多人建议我直接学SSM,SSM看了一段时间后发现很多东西虽然可以用了,但是并不是很了解,所以我打算重新来过.从SSH开始学习,前面已经大致的学习了Hibernate,对于Hibern ...
- Struts2学习(一)————Struts2入门
首先推荐一本书,虽然我还没看过,但是我以后肯定会看的,<Struts+技术内幕>提取密码:kg6w .现在只是停留在会使用struts2的层次,自己也想继续深入研究,但是感觉自己的知识面还 ...
- Struts2 学习笔记(概述)
Struts2 学习笔记 2015年3月7日11:02:55 MVC思想 Strust2的MVC对应关系如下: 在MVC三个模块当中,struts2对应关系如下: Model: 负责封装应用的状态,并 ...
- NoSQL之【MongoDB】学习(三):配置文件说明
摘要: 继上一篇NoSQL之[MongoDB]学习(一):安装说明 之后,知道了如何安装和启动MongoDB,现在对启动时指定的配置文件(mongodb.conf)进行说明,详情请见官方. 启动Mon ...
- 【Struts2学习笔记-3】常量配置
Struts2常量 配置Struts2常量值有3个地方,1)在struts.properties文件中配置常量:2)在web.xml文件中配置FileterDispatcher指定初始化参数来配置常量 ...
随机推荐
- c#的字典序
//Dictionary System.Collections.DictionaryEntry dic=new System.Collections.DictionaryEntry("key ...
- mybatis 关联查询时,从表只返回第一条记录解决办法
如果两表联查,主表和明细表的主键都是id的话,明细表的多条只能查询出来第一条. 造成以上情况可能的原因: 1.级联查询的时候,主表和从表有一样的字段名的时候,在mysql上命令查询是没问题的.但在my ...
- 洛谷 [P3620] 数据备份
贪心神题 首先我们发现一个显然的贪心策略,连接相邻两个写字楼总是更优. 所以本题就变成了数轴上一堆点,要选 k 个彼此不相邻的区间,使得区间长度最小 对于 10000 的数据来说,我们可以用 DP 解 ...
- 给页面上所有的a标签增加随机数每次点击保证最新
$(document).click(function(){ $("a").each(function(){ if($(this).parent().parent().hasClas ...
- 此时不应有 \Microsoft (转)
原文转自 http://www.tuicool.com/articles/J7RFRz 下载boost库后,在cmd中运行bootstrap.bat ,输出 "此时不应有 \Microsof ...
- vSphere虚拟化ESXI6.0+vclient安装部署
知识部分:一.什么是vSphere?vSphere是VNware公司在2001年基于云计算推出的一套企业级虚拟化解决方案.核心组件为ESXi.如今,经历了5个版本的改进,已经实现了虚拟化基础架构. ...
- 【原创】SSAS 实例重命名
在某些时候我们可能想对现有的SSAS实例进行重命名之类的,比如:我以前有两个SSAS,一个2005,一个2008R2,其中我们2005是一开始安装的,并且是默认实例,2008R2是命名实例,但是随着使 ...
- 洛谷——P2383 狗哥玩木棒
P2383 狗哥玩木棒 题目背景 狗哥又趁着语文课干些无聊的事了... 题目描述 现给出一些木棒长度,那么狗哥能否用给出的木棒(木棒全用完)组成一个正方形呢? 输入输出格式 输入格式: 输入文件中的第 ...
- SSH做反向代理
说实话,我对反向代理这个概念并不熟悉,只是感觉以下要做的事是一个代理的逆向过程,故借此名词一用. 问题场景是这样的:我有两套Linux集群的访问权限,分别为A和B,它们互相独立.其中A.B集群均能访问 ...
- Delphi 异或校验方法
//数据异或校验function BytesXor(buffer:array of byte):Integer;var i:integer;begin Result:=$0; for i:=Low(b ...