<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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>
<h1>Action 的访问</h1>
<h3>通过method方式</h3>
<a href="${ pageContext.request.contextPath}/userFind.action">查询用户</a>
<a href="${ pageContext.request.contextPath}/userUpdate.action">修改用户</a>
<a href="${ pageContext.request.contextPath}/userDelete.action">删除用户</a>
<a href="${ pageContext.request.contextPath}/userSave.action">保存用户</a>
<h3>通过通配符的方式</h3>
<a href="${ pageContext.request.contextPath}/product_find.action">查询商品</a>
<a href="${ pageContext.request.contextPath}/product_update.action">修改商品</a>
<a href="${ pageContext.request.contextPath}/product_delete.action">删除商品</a>
<a href="${ pageContext.request.contextPath}/product_save.action">保存商品</a>
<h3>通过动态方法访问 的方式</h3>
<a href="${ pageContext.request.contextPath}/customer!find.action">查询客户</a>
<a href="${ pageContext.request.contextPath}/customer!update.action">修改客户</a>
<a href="${ pageContext.request.contextPath}/customer!delete.action">删除客户</a>
<a href="${ pageContext.request.contextPath}/customer!save.action">保存客户</a>
</body>
</html>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>
<package name="default" namespace="/" extends="struts-default">
<global-results>
<result name="success">/hello.jsp</result>
</global-results>
<action name="userFind" class="cn.hello01.UserAction" method="find"></action>
<action name="userSave" class="cn.hello01.UserAction" method="save"></action>
<action name="userDelete" class="cn.hello01.UserAction" method="delete"></action>
<action name="userUpdate" class="cn.hello01.UserAction" method="update"></action>
<action name="login" class="cn.hello01.helloAction" method=""></action>
<action name="login2" class="cn.hello01.helloAction2" method=""></action>
<action name="login3" class="cn.hello01.helloAction3" method=""></action>
<action name="product_*" class="cn.hello01.ProductAction" method="{1}"></action>
<action name="customer" class="cn.hello01.CustomerAction"></action>
</package>
</struts>
package cn.hello01;
import com.opensymphony.xwork2.ActionSupport;
public class CustomerAction extends ActionSupport{
public String find(){
System.out.println("查询客户");
return NONE;
}
public String save(){
System.out.println("保存客户");
return NONE;
}
public String delete(){
System.out.println("删除客户");
return NONE;
}
public String update(){
System.out.println("更新客户");
return NONE;
}
}