Struts2-整理笔记(二)常量配置、动态方法调用、Action类详解
1.修改struts2常量配置(3种)
第一种
在str/struts.xml中添加constant标签
<struts>
<!-- 如果使用使用动态方法调用和include冲突 -->
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<!-- 开发者模式 -->
<constant name="struts.devMode" value="true" />
</struts>
第二种
src下新建一个struts.properties
struts.enable.DynamicMethodInvocation=true
struts.devMode=true
第三种
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <context-param>
<param-name>struts.i18n.encoding</param-name>
<param-value>UTF-8</param-value>
</context-param> </web-app>
2.常用的常量配置
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd"> <struts>
<!-- 配置动态方法调用是否开启常量 默认是关闭的,需要手动开启 -->
<constant name="struts.enable.DynamicMethodInvocation" value="true" /> <package name="dynamic" namespace="/dynamic" extends="struts-default">
<action name="Demo1Action" class="cn.zhr.Demo1Action">
<result name="success" type="dispatcher">hello.jsp</result>
</action>
</package>
</struts>
第二步 通过输入网站地址 要使用!跟方法名
http://localhost:8080/struts2_day01/dynamic/Demo1Action!add
方式二
利用通配符使用{来取出*号的内容}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd"> <struts>
<!-- 配置动态方法调用是否开启常量 默认是关闭的,需要手动开启 -->
<constant name="struts.enable.DynamicMethodInvocation" value="true" /> <package name="dynamic" namespace="/dynamic" extends="struts-default">
<action name="Demo1Action_*" class="cn.zhr.Demo1Action" method="{1}">
<result name="success" type="dispatcher">hello.jsp</result>
</action>
</package>
</struts>
http://localhost:8080/struts2_day01/dynamic/Demo1Action_add.action
4.action类详解
Struts2-整理笔记(二)常量配置、动态方法调用、Action类详解的更多相关文章
- JAVAEE学习——struts2_01:简介、搭建、架构、配置、action类详解和练习:客户列表
一.struts2是什么 1.概念 2.struts2使用优势以及历史 二.搭建struts2框架 1.导包 (解压缩)struts2-blank.war就会看到 2.书写Action类 public ...
- c# 把一个匿名对象赋值给一个Object类型的变量后,怎么取这个变量? c# dynamic动态类型和匿名类 详解C# 匿名对象(匿名类型)、var、动态类型 dynamic 深入浅析C#中的var和dynamic
比如有一个匿名对象,var result =......Select( a=>new { id=a.id, name=a.name});然后Object obj = result ;我怎 ...
- struts2的action类详解
Action类的书写方式 方式1
- JavaWeb_(Struts2框架)struts.xml核心配置、动态方法调用、结果集的处理
此系列博文基于同一个项目已上传至github 传送门 JavaWeb_(Struts2框架)Struts创建Action的三种方式 传送门 JavaWeb_(Struts2框架)struts.xml核 ...
- Struts2学习笔记二 配置详解
Struts2执行流程 1.简单执行流程,如下所示: 在浏览器输入请求地址,首先会被过滤器处理,然后查找主配置文件,然后根据地址栏中输入的/hello去每个package中查找为/hello的name ...
- 2018.12.15 struts.xml 一般配置文件写法 && 配置动态方法
struts.xml 原始配置文件 配置 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE s ...
- struts2.5+框架使用通配符与动态方法
概述:struts2.5以后加强了安全性,下面就是安全配置引发的问题 通配符: 在学习struts框架时经常会使用到通配符调用方法,如下: <package name="usercru ...
- struts2-环境搭建-访问流程-配置详解-常量配置-类详解
1 struts2概述 1.1 概念 1.2 struts2使用优势 自动封装参数 参数校验 结果的处理(转发|重定向) 国际化 显示等待页面 表单的防止重复提交 struts2具有更加先进的架构以 ...
- 01_5_Struts_ActionMethod_DMI_动态方法调用
01_5_Struts_ActionMethod_DMI_动态方法调用 1. ActionMethod_DMI_动态方法调用 Action执行的时候并不一定要执行execute()方法 可以在配置文件 ...
随机推荐
- Libevent 事件循环(1)
// 事件的dispatch int event_base_loop(struct event_base *base, int flags) { //得到采用的事件模型 epoll/epoll/ ...
- Nginx的知识分享,技术分享
3. Nginx常用命令管理及升级 查看nginx进程 ps -ef|grep nginx 说明:nginx的进程由主进程和工作进程组成. 启动nginx nginx 启动结果显示nginx的主线程和 ...
- npm install 时报错 Unexpected end of input at 1:15930
从github上clone代码后npm install,结果解决办法: npm config set registry https://registry.npm.taobao.org之后出现自动生成了 ...
- php IP转换整形(ip2long)
如何将四个字段以点分开的IP网络址协议地址转换成整数呢?PHP里有这么一个函数ip2long.比如 <?php echo ip2long("10.2.1.3"); ?> ...
- 基于Spring Aop实现类似shiro的简单权限校验功能
在我们的web开发过程中,经常需要用到功能权限校验,验证用户是否有某个角色或者权限,目前有很多框架,如Shiro Shiro有基于自定义登录界面的版本,也有基于CAS登录的版本,目前我们的系统是基于C ...
- pipelineDB初体验
官网:http://www.pipelinedb.com/ pipelineDB是基于postgres的stream数据库.完全兼容pg的东西. 由于产品需要解决性能这块瓶颈,老大让试试这款基于流计算 ...
- 【机器学习】RNN学习
感谢中国人民大学的胡鹤老师,课程容量巨大,收获颇丰. 之前提到的CNN模型主要用到人类的视觉中枢,但其有一劣势,无论是人类的视觉神经还是听觉神经,所接受到的都是一个连续的序列,使用CNN相当于割裂了前 ...
- MySQL InnoDB四个事务级别 与 脏读、不反复读、幻读
MySQL InnoDB事务隔离级别脏读.可反复读.幻读 希望通过本文.能够加深读者对ySQL InnoDB的四个事务隔离级别.以及脏读.不反复读.幻读的理解. MySQL InnoDB事务的隔离级别 ...
- java.lang.IllegalStateException: attempt to re-open an already-closed object
attempt to re-open an already-closed object 字面理解,试图再次打开已经关闭的对象.这是我在操作sqlited的时候出现的错误, 我在一个activity里面 ...
- OracleOraDb11g_home1TNSListener服务启动后停止,某些服务在未由其他服务或程序使用时将自己主动停止
解决的方法,大家来分享一下 1:注冊表中 HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/services/OracleOraDb11g_home1TNSLis ...