STRUTS2配置动态页面
CreateTime--2017年5月11日09:00:31
Author:Marydon
1.struts配置
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<!-- struts2配置 --> <!-- struts2常用配置 START -->
<!--指定web应用的默认编码集,相当于调用HttpServletRequest.setCharacterEncoding方法 -->
<constant name="struts.i18n.encoding" value="UTF-8" />
<!-- 指定需要struts2处理的请求后缀,默认值为action. 如果用户需要指定多个请求后缀,则多个后缀之间以英语逗号(,)隔开 -->
<constant name="struts.action.extension" value="do" /> <!--当struts.xml文件改变后,系统是否自动的重新加载该文件,默认值为false -->
<constant name="struts.configuration.xml.reload" value="true" /> <!--
是否应用开发模式. 通常,应在开发阶段设置为true,出错时显示更多、更友好的出错提示; 当进入产品发布阶段后,应该设置为false
-->
<constant name="struts.devMode" value="true" />
<!--当找不到url时是否根据namespace向上级路径查询,默认值为false -->
<constant name="struts.mapper.alwaysSelectFullNamespace" value="true"></constant>
<!--配置上传文件大小 -->
<constant name="struts.multipart.maxSize" value="10000000" />
<constant name="struts.multipart.saveDir " value="" />
<!--
该属性指定Struts 2框架默认加载的配置文件,如果需要指定默认加载多个配置文件, 则多个配置文件的文件名之间以英文逗号(,)隔开。
该属性的默认值为struts-default.xml,struts-plugin.xml,struts.xml
-->
<constant name="struts.configuration.files" value="struts-default.xml" />
<!-- END struts2常用配置 --> <!-- 配置动态页面 -->
<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant> <package name="PATIENT" extends="struts-platform" namespace="/telemedicine/patient">
<!-- 查询
已申请的*、已安排的*、未通过的*、已撤销的*、*审核、*报告、未完成的*、已完成的*、*效果评价
所对应的列表页面
-->
<action name="index" class="telemedicine.web.actions.reseCons.PATIENT_Action" method="index">
<!-- 动态页面 -->
<result name="success" type="dispatcher">${dispatcherPath1}</result>
</action>
</package>
</struts>
2.Action类配置
//首页页面转发路径
private String dispatcherPath1;
//生成对应的get、set方法
public String getDispatcherPath1() {
return dispatcherPath1;
} public void setDispatcherPath1(String dispatcherPath1) {
this.dispatcherPath1 = dispatcherPath1;
} // 转发路径
String dPath = "";
// 状态:根据不同的状态值设置不同的页面路径
// 自定义状态(用于区分跳转页面) 1:已申请的*;2:已撤销的*;3:*审核;4:未通过的*;
// 5:已安排的*;6:未完成的*;7:*报告;8:已完成的*;9:*效果评价(9 未定)
String modelAndView = ""; /**
* *审核信息表
* @return 导航到首页
*/
public String index() {
try {
// 必要参数:跳转页面-modelAndView
paramsMap = WebUtils.getParameterMap();
// modelAndView为必要参数
if (paramsMap.containsKey("modelAndView")) {
// 自定义状态(用于区分跳转页面) 1:已申请的*;2:已撤销的*;3:*审核;4:未通过的*;
// 5:已安排的*;6:未完成的*;7:*报告;8:已完成的*;9:*效果评价(9 未定)
modelAndView = paramsMap.get("modelAndView").toString().trim(); if ("1".equals(modelAndView))
dPath = "/telemedicine/remoteRese/consAlready/consAleady_records.jsp";// 已申请的*
else if ("2".equals(modelAndView))
dPath = "/telemedicine/remoteRese/consRevoked/consRevoked_records.jsp";// 已撤销的*
else if ("3".equals(modelAndView))
dPath = "/telemedicine/remoteCons/consReview/consReview_records.jsp";// *审核
else if ("4".equals(modelAndView))
dPath = "/telemedicine/remoteRese/consNopass/consNopass_records.jsp";// 未通过的*
else if ("5".equals(modelAndView))
dPath = "/telemedicine/remoteRese/consPlannad/consPlannad_records.jsp";// 已安排的*
else if ("6".equals(modelAndView))
dPath = "/telemedicine/remoteCons/consUncomp/consUncomp_records.jsp";// 未完成的*
else if ("7".equals(modelAndView))
dPath = "/telemedicine/remoteCons/consReport/consReport_records.jsp";// *报告
else if ("8".equals(modelAndView))
dPath = "/telemedicine/remoteCons/consComp/consComp_records.jsp";// 已完成的*
else if ("9".equals(modelAndView))
dPath = "/telemedicine/remoteCons/consEval/consEval_records.jsp";// *效果评价 // 设置跳转页面路径
this.setDispatcherPath1(dPath);
}
} catch (Exception e) {
this.code = -1;
this.msg = e.getMessage();
this.expMsg = getExceptionMessage(e);
log.error(e.getMessage());
}
return getResult();
}
要点解析:
1.struts转发路径用"${动态值}"代替死值;
2.在Action类中生成动态值的get(),set()方法。
STRUTS2配置动态页面的更多相关文章
- [置顶] 自己动手写Web容器之TomJetty之六:动态页面引入
传送门 ☞ 1.Web服务内功经脉 传送门 ☞ 2.让服务动起来 传送门 ☞ 3.掀起请求盖头来 传送门 ☞ 4.静态页面起步 传送门 ☞ 5.包装请求参数 在上一节,我们已经完成了TomJetty服 ...
- Struts2的动态Action和全局跳转视图以及配置各项默认值
1:Struts2的默认访问后缀是.action(特别需要注意的是改了配置文件web.xml或者struts.xml需要重启服务器) 2:Struts2中常用的常量介绍:<!-- 一:全局配置 ...
- Spring MVC 学习总结(七)——FreeMarker模板引擎与动态页面静态化
模板引擎可以让程序实现界面与数据分离,业务代码与逻辑代码的分离,这就提升了开发效率,良好的设计也使得代码复用变得更加容易.一般的模板引擎都包含一个模板解析器和一套标记语言,好的模板引擎有简洁的语法规则 ...
- Struts2 配置详解
1. web.xml 此文件的配置可以参看struts2的示例文档 <filter> <filter-name>struts2</filter-name> < ...
- Struts2配置详解_配置Action
Struts2的核心功能是action,对于开发人员来说,使用Struts2主要就是编写action,action类通常都要实现com.opensymphony.xwork2.Action接口,并实现 ...
- 动态页面技术JSP/EL/JSTL
本节内容: jsp脚本和注释 jsp运行原理 jsp指令(3个) jsp内置/隐式对象(9个) jsp标签(动作) EL技术 JSTL技术 JavaEE的开发模式 动态页面技术:就是在html中嵌入j ...
- Struts2 配置Action详解
Struts2的核心功能是action,对于开发人员来说,使用Struts2主要就是编写action,action类通常都要实现com.opensymphony.xwork2.Action接口,并实 ...
- Struts2的动态Action实现
源自:Struts2的动态Action实现 在Struts2中动态方法调用有三种方式. 一.指定method属性在struts.xml中指定action的method属性. <package n ...
- 2018.12.15 struts.xml 一般配置文件写法 && 配置动态方法
struts.xml 原始配置文件 配置 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE s ...
随机推荐
- spoj4155 OTOCI LCT
动态树,支持加边,修改点权,查询链的点权和. #include <cstdio> #include <iostream> #define maxn 30010 using na ...
- [转]Activity详解 Intent显式跳转和隐式跳转
Activity 生命周期 显式 Intent 调用 1 //创建一个显式的 Intent 对象(方法一:在构造函数中指定) 2 Inte ...
- BZOJ 2243: [SDOI2011]染色 树链剖分 倍增lca 线段树
2243: [SDOI2011]染色 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/pr ...
- Ubuntu 11.04安装GCC 4.6.1
首先下载相应的源代码:ftp://ftp.dti.ad.jp/pub/lang/gcc/releases/gcc-4.6.1/#下载 gcc-4.6.1.tar.bz2 ftp://ftp.dti.a ...
- UltraEdit字体设置(fontlink大法)
在网上游荡很久,查阅诸多资料,终于为UltraEdit选定了一套我喜欢的字体方案.这套字体方案是:英文字体使用Consolas,中文字体使用微软雅黑. 虽然说起来好像很清楚,但是因为在UltraEdi ...
- FIS3使用官方例子流程
fis3 的常用例子:https://github.com/fex-team/fis3-demo git链接可在页面中获取替换下面的git链接: 例子准备: git clone https://git ...
- 如何编译Linux内核
内核,是一个操作系统的核心.它负责管理系统的进程.内存.设备驱动程序.文件和网络系统,决定着系统的性能和稳定性.Linux作为一个自由软件,在广 大爱好者的支持下,内核版本不断更新.新的内核修订了旧内 ...
- appium+python自动化24-滑动方法封装(swipe)
swipe介绍 1.查看源码语法,起点和终点四个坐标参数,duration是滑动屏幕持续的时间,时间越短速度越快.默认为None可不填,一般设置500-1000毫秒比较合适. swipe(self, ...
- u3d移动游戏优化规范
1.顶点性能一般来说,如果您想在iPhone 3GS或更新的设备上每帧渲染不超过40,000可见点,那么对于一些配备 MBX GPU的旧设备(比如,原始的 iPhone,如 iPhone 3g和 iP ...
- Mysql中DATE_SUB函数
在对数据查询或菜单时经常要对指定的时间或时间段进行查询,例如要查询一天内的信息,要查询一周内的信息,要查询一个月内的. 定义和用法 DATE_SUB() 函数从日期减去指定的时间间隔. 1.语法 DA ...