DMI(Dynamic Method Invocation) 动态方法调用
2014-06-23 20:50
232 查看
创建action,内容如下:
配置struts.xml,内容如下:
创建hello.jsp,内容如下:
在浏览器上动态访问action的方法,如下图:
package action; import com.opensymphony.xwork2.ActionSupport; public class A extends ActionSupport { public String toJsp(){ return "success"; } }
配置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="A" class="action.A"> <result>/hello.jsp</result> </action> <!-- DMI(动态方法调用),可以在浏览器地址栏上动态的给出action执行的方法名称 http://localhost:8081/Test2/A!toJsp,A是action的名称,toJsp是action中的方法 --> </package> </struts>
创建hello.jsp,内容如下:
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> Welcome to Struts2 </body> </html>
在浏览器上动态访问action的方法,如下图:
相关文章推荐
- struts.enable.DynamicMethodInvocation = true 动态方法调用(转)
- struts.enable.DynamicMethodInvocation = true 动态方法调用
- struts.enable.DynamicMethodInvocation = true 动态方法调用
- struts.enable.DynamicMethodInvocation = true 动态方法调用
- Struts2 ActionMethod 【DMI】(动态方法调用 Dynamic Method Invoke)
- struts.enable.DynamicMethodInvocation = true 动态方法调用(转)
- struts.enable.DynamicMethodInvocation = true 动态方法调用
- struts2 2.5动态方法调用(DMI) dynamic method invoke 出现不被允许的方法时 Method add for action dynamic is not allowed! - [unknown location]
- struts.enable.DynamicMethodInvocation = true 动态方法调用
- struts.enable.DynamicMethodInvocation = true 动态方法调用
- struts2 ActionMethod DMI 动态方法调用
- struts2配置及ActionMethod_DMI_动态方法调用
- Struts2 ActionMethod DMI(动态方法调用)
- ActionMethod 动态方法调用(DMI)
- struts2学习(4)struts2中的动态方法调用(DMI)
- [深入浅出Cocoa]之消息(二)-详解动态方法决议(Dynamic Method Resolution)
- 远程方法调用(Remote Method Invocation,RMI)
- Struts 2---动态调用方法(DMI)
- Struts2的动态方法调用DMI
- Struts2中DMI(动态方法调用)的一些问题