
package cn.hello01;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
public class UserAction extends ActionSupport{
	//增加
	public String save(){
		System.out.println("保存");
		return Action.SUCCESS;
	}
	//删除
	public String delete(){
		System.out.println("删除");
		return Action.SUCCESS;
	}
	//修改
	public String update(){
		System.out.println("修改");
		return Action.SUCCESS;
	}
	//查询
	public String find(){
		System.out.println("查找");
		return Action.SUCCESS;
	}
}

<%@ 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>
</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>
   
    <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>  
    </package>
</struts>

 
 


















![[flask]请求全局钩子](https://img-blog.csdnimg.cn/direct/f4b46ae8e5d344a78629c62b55816f49.png)
