DMI ( Dynamic Method Invocation )
功能:

点击 hello , 调用 execute 函数
点击 update , 调用 update 函数
1.项目结构

2.web.xml
<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
3.UserAction.java
package com.action;
import com.opensymphony.xwork2.ActionSupport; public class UserAction extends ActionSupport {
private static final long serialVersionUID=1L;
private String info;
public String getInfo()
{
return info;
}
public void setINfo(String info)
{
this.info=info;
}
public String execute() throws Exception{
info="hello world bb!";
return "hello";
}
public String update() throws Exception{
info="ok,updated!";
return "update";
}
}
4.index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!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>Insert title here</title>
</head>
<body>
<center>
<a href="user_execute">hello</a><br>
<a href="user_update">update</a>
</center>
</body>
</html>
5.struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" namespace="/" extends="struts-default">
<action name="user_*" class="com.action.UserAction" method="{1}">
<result name="hello">/hello.jsp</result>
<result name="update">/update.jsp</result>
</action>
</package>
</struts>
6.hello.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!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>Insert title here</title>
</head>
<body>
<center>
<s:property value="info" />
</center>
</body>
</html>
7.update.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!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>Insert title here</title>
</head>
<body>
<center>
<s:property value="info" />
</center>
</body>
</html>
DMI ( Dynamic Method Invocation )的更多相关文章
- struts2 CVE-2013-4316 S2-019 Dynamic method executions Vul
catalog . Description . Effected Scope . Exploit Analysis . Principle Of Vulnerability . Patch Fix 1 ...
- Spring Remoting: Remote Method Invocation (RMI)--转
原文地址:http://www.studytrails.com/frameworks/spring/spring-remoting-rmi.jsp Concept Overview Spring pr ...
- java的RMI(Remote Method Invocation)
RMI 相关知识RMI全称是Remote Method Invocation-远程方法调用,Java RMI在JDK1.1中实现的,其威力就体现在它强大的开发分布式网络应用的能力上,是纯Java的网络 ...
- Dynamic Method Resolution
[Dynamic Method Resolution] @dynamic directive 用于声明属性的方法dynamic loading,which tells the compiler tha ...
- Method Invocation Expressions
15.12.1. Compile-Time Step 1: Determine Class or Interface to Search The first step in processin ...
- Dynamic Method Binding in Delphi 动态方法绑定
Dynamic Method Binding in Delphi 动态方法绑定 https://docs.dataabstract.com/Delphi/AdvancedTopics/Dynamic ...
- javac之Method Invocation Expressions
15.12.1. Compile-Time Step 1: Determine Class or Interface to Search 15.12.2. Compile-Time Step 2: D ...
- K:java中的RMI(Remote Method Invocation)
相关介绍: RMI全称是Remote Method Invocation,即远程方法调用.它是一种计算机之间利用远程对象互相调用,从而实现双方通讯的一种通讯机制.使用这种机制,某一台计算机(虚拟机) ...
- method invocation
package method.invocation; public class MethodInvocation { public static void main(String[] args) { ...
随机推荐
- net软件工程师求职简历
Net软件工程师求职简历 姓 名: 王静静 性 别: 女 出生日期: 1991-12 籍 贯: 河北 居住地: 北京 学 历: 专科 E-mail: 335659753@qq. ...
- 【Zookeeper】源码分析之持久化--FileTxnLog
一.前言 前一篇已经分析了序列化,这篇接着分析Zookeeper的持久化过程源码,持久化对于数据的存储至关重要,下面进行详细分析. 二.持久化总体框架 持久化的类主要在包org.apache.zook ...
- php集成环境和自己配置的区别,php集成环境、php绿色集成环境、php独立安装版环境这三者的区别
最近有学生问我,直接使用PHP集成环境和我们自己独立安装的php环境有什么不一样吗? 答:PHP集成环境,和自己安装的php环境实际上没啥区别的,只不过大部分的集成环境进行了一些绿化操作,本质上没啥区 ...
- Composer入门
摘要 本文介绍Composer的入门知识,包括require和autoload部分. Java有Maven, Node.js有npm, ROR有gem, 这些语言的程序员在开心地使用包管理工具加速开发 ...
- Python高手之路【九】python基础之迭代器与生成器
迭代器与生成器 1.迭代器 迭代器是访问集合元素的一种方式.迭代器对象从集合的第一个元素开始访问,直到所有的元素被访问完结束.迭代器只能往前不会后退,不过这也没什么,因为人们很少在迭代途中往后退.另外 ...
- 在转换为 UTC 时大于 DateTime.MaxValue 或小于 DateTime.MinValue 的 DateTime 值无法系列化为 JSON
看到这个错往往会感到莫名其妙! 其原因其实是数据库的DateTime最小值和C#的DateTime不一样 Sql Server DateTime 类型必须介于 1/1/1753 12:00:00 AM ...
- 第一百三十一节,JavaScript,封装库--CSS
JavaScript,封装库--CSS 将封装库里的方法,改成了原型添加方法 增加4个方法 tian_jia_class()方法,给获取到的元素添加class属性,参数是class属性值,可以连缀1 ...
- 基于python第三方requests 模块的HTTP请求类
使用requests模块构造的下载器,首先安装第三方库requests pip install requests 1 class StrongDownload(object): def __init_ ...
- 自动布局autolayout和sizeclass的使用
一.关于自动布局(Autolayout) 在Xcode中,自动布局看似是一个很复杂的系统,在真正使用它之前,我也是这么认为的,不过事实并非如此. 我们知道,一款iOS应用,其主要UI组件是由一个个相对 ...
- Colorful Image Colorization 的环境配置
原文链接:https://github.com/richzhang/colorization 步骤基本是按照Installation里的说明 1.安装依赖库 1.1Python相关库 Python l ...