start.jsp :
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<title>Insert title here</title>
</head>
<body>
<a href="sample01">sample01</a><br>
<a href="sample02">sample02</a>
</body>
</html>
struts.xml :
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
<struts>
<package name="demo" extends="struts-default">
<action name="sample01" class="action.Sample01Action">
<result name="success">/sample01.jsp</result>
</action>
<action name="sample02" class="action.Sample02Action">
<result name="success">/sample02.jsp</result>
</action>
</package>
</struts>
Sample01Action.java :
public class Sample01Action {
public String execute(){
return "success";
}
}
Sample02Action.java :
public class Sample02Action {
public String execute(){
return "success";
}
}
sample01.jsp :
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Insert title here</title>
</head>
<body>
sample01.jsp...
<hr>
<s:action name="sample02" executeResult="true"></s:action> //标签在这
</body>
</html>
sample02.jsp :
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<title>Insert title here</title>
</head>
<body>
sample02.jsp...
</body>
</html>
点击sample01链接,得到: