ActionMethod_DMI_动态方法调用
Action执行的时候并不一定要执行execute方法
可以在配置文件中配置Action的时候用method=来指定执行那个方法,也可以在url地址中动态指定(动态方法调用DMI)(推荐)
动态方法调用的配置要先打开:
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>
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>
<h1>Hello World~~~</h1>
Action执行的时候并不一定要执行execute方法<br>
可以在配置文件中配置Action的时候用method=来指定执行那个方法,也可以在url地址中动态指定(动态方法调用DMI)(推荐)<br>
<a href="user/userAdd">添加用户</a><br>
<a href="user/user!add">添加用户</a><br>
前者会产生太多的action,所以不推荐使用
</body>
</html>
struts.xml
<?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.configuration.xml.reload" value="true"/>
<constant name="struts.enable.DynamicMethodInvocation" value="true"/> <!-- namespace 必须 "/" 开头 -->
<package name="user" namespace="/user" extends="struts-default">
<action name="userAdd" class="com.bjsxt.struts2.user.action.UserAction" method="add">
<result>/user_add_success1.jsp</result>
</action> <action name="user" class="com.bjsxt.struts2.user.action.UserAction">
<result>/user_add_success.jsp</result>
</action>
</package> </struts>
UserAction
package com.bjsxt.struts2.user.action; import com.opensymphony.xwork2.ActionSupport; public class UserAction extends ActionSupport{ private static final long serialVersionUID = -1735844624241755443L; public String add(){
return SUCCESS;
}
}
链接: http://pan.baidu.com/s/1skZG6Gd 密码: pxeb
ActionMethod_DMI_动态方法调用的更多相关文章
- 01_5_Struts_ActionMethod_DMI_动态方法调用
01_5_Struts_ActionMethod_DMI_动态方法调用 1. ActionMethod_DMI_动态方法调用 Action执行的时候并不一定要执行execute()方法 可以在配置文件 ...
- Struts2学习笔记 - Action篇<动态方法调用>
有三种方法可以使一个Action处理多个请求 动态方法调用DMI 定义逻辑Acton 在配置文件中使用通配符 这里就说一下Dynamic Method nvocation ,动态方法调用,什么是动态方 ...
- 第三章Struts2 Action中动态方法调用、通配符的使用
01.Struts 2基本结构 使用Struts2框架实现用登录的功能,使用struts2标签和ognl表达式简化了试图的开发,并且利用struts2提供的特性对输入的数据进行验证,以及访问Servl ...
- Struts2 动态方法调用
01.Struts 2基本结构 使用Struts2框架实现用登录的功能,使用struts2标签和ognl表达式简化了试图的开发,并且利用struts2提供的特性对输入的数据进行验证,以及访问Servl ...
- struts之动态方法调用使用通配符
一.DMI动态方法调用的其中一种改变form表单中action属性的方式已经讲过了.还有两种,一种是改变struts.xml配置文件中action标签中的method属性,来指定执行不同的方法处理不同 ...
- struts之动态方法调用改变表单action属性
一.动态方法调用(DMI:Dynamic Method Invocation) ⒈struts2中同样提供了这个包含多个逻辑业处理的Action,这样就可以在一个Action中进行多个业务逻辑处理 ...
- struts2DMI(动态方法调用)
struts2动态方法调用共有三种方式: 1.通过action元素的method属性指定访问该action时运行的方法 <package name="action" exte ...
- Struts2 Action中动态方法调用、通配符的使用
一.Struts2执行过程图: 二.struts2配置文件的加载顺序 struts-default.xml---struts-plugin.xml---struts.xml 具体步骤: 三.Actio ...
- Struts(八):动态方法调用
动态方法调用:通过url动态调用action中的方法. 默认情况下,Struts的动态方法调用处于禁用状态. 测试定义一个action类: package com.dx.actions; public ...
随机推荐
- kuangbin专题十六 KMP&&扩展KMP POJ2406 Power Strings
Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc&quo ...
- leecode第三题(无重复字符的最长子串)
class Solution { public: int lengthOfLongestSubstring(string s) { int len=s.size(); ||len==)//边界 ret ...
- Linode安装环境
Ubuntu 18 密码:Fenghaiyan35 netstat -plnt //查看所有文件 sudo apt-get install apac ...
- js常用代码收集
1. PC - js 返回指定范围的随机数(m-n之间)的公式 Math.random()*(n-m)+m return false return false // event.preventDefa ...
- IDEA 文档注释 乱码 终极... 解决方案
idea bin 目录 下 phpstorm64.exe.vmoptions 最后一行添加 : -Dfile.encoding=UTF-8
- SharePoint开发中可能用到的各种Context(上下文)
转载: http://www.cnblogs.com/erucy/archive/2012/08/25/2655600.html 电脑正在以无比慢的速度从微软网站上安装Office Component ...
- The MathType DLL cannot be found 一劳永逸的方法
可能会看到下面的情况,然后实际上我们也能用过外部打开直接使用,那要你何用? 于是,我们找到这个文件,删除就OK 反正我写完论文就卸载了...
- python自动化day1
一.变量 变量定义的规则: 变量名只能是 字母.数字或下划线的任意组合 变量名的第一个字符不能是数字 以下关键字不能声明为变量名['and', 'as', 'assert', 'break', 'cl ...
- SqlServer自动备份作业
/*********完整备份作业*********/ –完整备份,每周一次 USE Master GO declare @str varchar(100) set @str='D:\DBtext\jg ...
- tcp的半连接与完全连接队列(二)
队列及参数 server端的半连接队列(syn队列) 在三次握手协议中,服务器维护一个半连接队列,该队列为每个客户端的SYN包开设一个条目(服务端在接收到SYN包的时候,就已经创建了request_s ...