huageniuniude
2016-05-24 19:59
方法类: package Action; import com.opensymphony.xwork2.ActionSupport; public class test extends ActionSupport { public String execute() throws Exception { System.out.print("executed"); return SUCCESS; } public String add(){ return SUCCESS; } }
配置文件: <?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="defult" namespace="/" extends="struts-default"> <action name="test" class="Action.test"> <result>/test.jsp</result> </action> <action name="add" method="add" class="Action.test"> <result>/add.jsp</result> </action> </package> </struts>
url:http://localhost:8080/MyfirstStruts2/add.action
默认执行了execute(),因为你的第一个<action>没配置method。
Struts2入门
95061 学习 · 456 问题
相似问题