struts2 action的动态应用(DMI)
来源:互联网 发布:linux sync用户 编辑:程序博客网 时间:2024/04/30 04:48
1.创建action 类
package com.demo.action;importcom.opensymphony.xwork2.ActionSupport;publicclass userAction extends ActionSupport { /** * */ private static final long serialVersionUID = 1L; private String info; //提示信息 //添加用户信息 public String add() throws Exception { info = "add" ; return info ; } //更新用户信息 public String update() throws Exception { info = "update" ; return info ; } public String getInfo() { return info ; } public void setInfo(String info) { this .info = info; }}2.配置struts.xml
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts><!-- 声明包 --><constant name="struts.enable.DynamicMethodInvocation" value="true" /> <package name="myPackage" extends="struts-default" namespace="/"> <!-- 定义action --> <action name="userAction" class="com.demo.action.userAction" > <result name="update">/user_update.jsp</result> <result name="add">/user_add.jsp</result> <result >/first.jsp</result> </action> </package></struts>
注意:我用的是2.3版本的,如果添加<constant name ="struts.enable.DynamicMethodInvocation" value= "true" /> 显式声明使用DMI,则失败
name= "update"中update为你要调用的函数的返回值,如果return success;则直接转向第三个result,也就是result为默认的。
< body> <a href= "userAction"> 转向第一个页面 </ a> <!--跳向第三个result--> <br > <a href= "userAction!add" >添加用户 </ a> <!--跳向第二个result--> <br > <a href= "userAction!update"> 更新用户 </a > <!--跳向第一个result--></ body>
- struts2 action的动态应用(DMI)
- struts2 04 DMI Action动态访问
- struts2 action DMI动态方法调用
- Struts2关于Action的系统训练4关于动态方法调用DMI
- Struts2的动态方法调用DMI
- Struts2-动态方法调用(DMI)
- struts2动态方法调用(DMI)
- Struts2 DMI 动态方法调用
- Struts2 DMI动态方法调用
- Struts2中DMI(动态方法调用)的错误问题(There is no Action mapped for namespace [/xxx] and action name [xxx!yyy] a)
- Struts2中DMI(动态方法调用)的一些问题
- 关于Struts2 namespace 的学习笔记(DMI动态方法调用)
- Struts2中DMI(动态方法调用)的一些问题
- Struts2中DMI(动态方法调用)的一些问题
- Struts2中(动态方法调用)DMI的一些问题
- struts2的动态方法调用(DMI)和通配符映射
- Struts2中DMI(动态方法调用)的一些问题
- Struts2中DMI(动态方法调用)的一些问题
- 迭代器(Iterator)
- xargs print0 相关记录
- Java之数据库连接(二)
- 详解在iOS后台执行
- 用java实现抽象类门Door,能进行开门(openDoor)关门(closeDoor)操作,有防盗,防水,防火,防锈,防弹功能
- struts2 action的动态应用(DMI)
- C++中的空类,默认产生哪些类成员函数
- java多态
- 委托基础之代码解析
- GCC 内联汇编语法
- 用libcurl和libjson实现人人网从APP key 获取access_token和session_key
- 在linux下使用redis的基础操作(一)
- 开博相关
- 字符串转换,将其中的大写字母变小写字母,小写字母变大写字母,并输出 。