SpringMVC用户信息的action层UserInfoAction的类

package com.gxa.bj.action;

import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.gxa.bj.model.UserInfo;
import com.gxa.bj.service.UserInfoService;
@Controller
public class UserInfoAction {
private UserInfoService userInfoService;

public UserInfoService getUserInfoService() {
return userInfoService;
}
public void setUserInfoService(UserInfoService userInfoService) {
this.userInfoService = userInfoService;
}
public List<UserInfo> getList(UserInfo u){
return userInfoService.getList(u);
}
@RequestMapping(value="/getalluser.action")
public ModelAndViewgetAllUser(){
ModelAndView modelView = new ModelAndView();
List<UserInfo> list = userInfoService.getList(null);
modelView.addObject("users",list);
modelView.setViewName("/index.jsp");
return modelView;

}

@RequestMapping(value="/login.action",method={RequestMethod.POST})
public String login(String txtUserName,String txtUserPwd) throws ServletException, IOException{
//req.setCharacterEncoding("utf-8");//设置参数的编码格式
// String userName = req.getParameter("txtUserName");
// String userPwd = req.getParameter("txtUserPwd");
// System.out.println("用户名:"+userName);
// System.out.println("密码:"+userPwd);
UserInfo u  = userInfoService.getLogin(txtUserName, txtUserPwd);
if(u!=null){
return "forward:/search.jsp";
}else{
return "redirect:/login.jsp";
}
}
@RequestMapping(value="/reg.action")
public void reg(UserInfo u){
System.out.println("用户名:"+u.getUserName());
}
@RequestMapping(value="/searchusers.action",method={RequestMethod.GET})
public ModelAndView searchUsers(String userName){
ModelAndView model = new ModelAndView();
UserInfo u = new UserInfo();
u.setUserName(userName);
List<UserInfo> list = userInfoService.getList(u);
model.addObject("users",list);
model.setViewName("/search.jsp");
return model;
}
@RequestMapping(value="/detail/{id}",method={RequestMethod.GET})
public ModelAndView detail(@PathVariable(value="id") Integer id){
System.out.println("hello");
ModelAndView model = new ModelAndView();
   UserInfo u = userInfoService.getUserInfo(id);
   model.addObject("user", u);
   model.setViewName("/user.jsp");
return model;
}

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值