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) { ...
随机推荐
- iOS上线项目源码分享
最强UINavigationController和TabBar结合(会员satian ) 最强UINavigationController和TabBar结合的Demo,这里取用了明星衣橱app里的 ...
- MySQL 笔记 —— 日期和时间函数
[TOC] 获取当前日期的函数和获取当前时间的函数 CURDATE()和CURRENT_DATE()函数获取当前日期:CURTIME()和CURRENT_TIME()函数获取当前时间. mysql&g ...
- dom4解析xml格式文件实例
以下给4种常见的xml文件的解析方式的分析对比: DOM DOM4J JDOM SAX 解析XML文件的几种方式和区别答: Dom解析 在内存中创建一个DOM树,该结构通常需要加载整个文档然后才能做工 ...
- WPF星空效果
效果 前阵子看到ay的蜘蛛网效果和知乎的登录页背景,觉得效果很酷.自己也想写一个.于是写着写着就变成这样了.少女梦幻的赶脚有木有.我这有着一颗少女心的抠脚大汉 实现思路 分为两个部分: 1.星星无休止 ...
- Head First设计模式——策略设计模式
策略设计模式 说在前面的话 入软件一年啦,平心而论,总算不限于只会钻研些基础的语言语法了,数据结构和算法也恶补的差不多了.所以~趁着现在一边实习一边啃<Head First设计模式>的功夫 ...
- MAC OS 常用软件及开发工具
1.各个版本的 Mac OS 链接: http://pan.baidu.com/s/1mgDtCi0 密码: 4y3u 2.Xcode xcode_4.6.3 链接: http://pan.baidu ...
- canvas实现画板功能(渐变、动画、阴影...)
刚刚在博客园落户了,希望能在这认识更多大神,希望能和大家交好朋友. 闲来无事,把以前用canvas写的画板代码改进了一番,用Html5提供的表单标签给其 加了一个选择颜色的功能,因此发现了该标签的一个 ...
- AForge.net 使用之录像拍照功能实现
连接摄像头设备,这里需要引入 AForge.Video; AForge.Video.DirectShow; AForge.Video.FFMPEG; 还需要添加引用,aforge.dll,aforge ...
- OBJECT-ORIENTED
- canvas画扇形图(本文来自于http://jo2.org/html5-canvas-sector/)
1.定义画扇形的构造函数: //扇形CanvasRenderingContext2D.prototype.sector = function (x, y, radius, sDeg, eDeg) {/ ...