ssh零配置心得

本文介绍了一个使用Struts2框架实现的用户管理Action类,包括用户信息的增删改查等功能。通过注入IUserManager服务接口来实现业务逻辑。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

package com.action;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import com.pojo.Userinfo;
import com.services.IUserManager;
@Controller
@Component
@Results({
		@Result(name="findAllSuccess",location="/checkUser.jsp"),
	    @Result(name="updateSuccess",location="/findAll.acttion",type="redirect"),
	    @Result(name="getSuccess",location="/getUser.jsp"),
	    @Result(name="saveSuccess",location="/findAll.action",type="redirect"),
	    @Result(name="saveError",location="/saveError.jsp"),
	    @Result(name="deleteSuccess",location="/findAll.action",type="redirect"),
	    @Result(name="toUpdateSuccess",location="/updateUser.jsp")
})
public class UserAction {
	private IUserManager um;
	private Userinfo user;
	private List<Userinfo> userList;
	
	public IUserManager getUm() {
		return um;
	}
	public Userinfo getUser() {
		return user;
	}
	public List<Userinfo> getUserList() {
		return userList;
	}
	public void setUserList(List<Userinfo> userList) {
		this.userList = userList;
	}
	@Autowired
	public void setUm(IUserManager um) {
		this.um = um;
	}
	public void setUser(Userinfo user) {
		this.user = user;
	}

	@Action("/save")
	public String save() {
		return um.save(user);
	}
	@Action("/toUpdate")
	public String toUpdate() {
		um.get(user);
		return "toUpdateSuccess";
	}
	@Action("/update")
	public String update() {
		return um.update(user);
	}

	@Action("/delete")
	public String delete() {
		return um.delete(user);
	}

	@Action("/get")
	public String get() {
		Userinfo userinfo = um.get(user);
		return "getSuccess";
		
	}
	@Action("/findAll")
	public String findAll() {
		userList = um.findAll();
		return "findAllSuccess";
	}
}
//要注意的地方1、需要注入的set方法上面要记得加@autowired。// 2、当想用一个action直接跳转到另外一个action上面时,记得加上type="redirect属性
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

gamestart104

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值