丶子非鱼
2017-05-12 19:11
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"> <struts> <package name="default" namespace="/" extends="struts-default"> <!-- action默认的method ="execute"--> <action name="index_*" method="{1}" class="com.action.HelloWorldAction"> <result name="add">/{1}.jsp</result> <result name="update">/{1}.jsp</result> <result> /HelloWorld.jsp</result> </action> </package> </struts>
package com.action; import com.opensymphony.xwork2.ActionSupport; @SuppressWarnings("serial") public class HelloWorldAction extends ActionSupport { @Override public String execute() throws Exception { System.out.println("执行成功"); return SUCCESS; } public String add() throws Exception { System.out.println("add执行成功"); return SUCCESS; } public String update() throws Exception { System.out.println("update执行成功"); return SUCCESS; } }
但是无论输入index_add 还是index_update 还是跳转到HelloWorld.jsp
你action的add,update方法返回的都是success,当然就匹配你的success结果集了(也就是result中没有写name的那个),然后就跳到HelloWorld.jsp了啊
Struts2入门
95062 学习 · 456 问题
相似问题