You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.1 KiB
53 lines
1.1 KiB
package com.ssm.controller.user;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import com.ssm.bean.User;
|
|
import com.ssm.service.UserService;
|
|
|
|
/**
|
|
* 控制层
|
|
* @author Nocol
|
|
*
|
|
*/
|
|
@Controller
|
|
@RequestMapping("/user")
|
|
public class UserAction {
|
|
//注入Service
|
|
@Autowired
|
|
private UserService userService;
|
|
|
|
@RequestMapping("regist")
|
|
public String regist(User user,Model model){
|
|
|
|
System.out.println("用户注册:"+user.getName()+user.getPassword());
|
|
|
|
user.setId(1);
|
|
userService.regist(user);
|
|
|
|
model.addAttribute("msg", "注册成功");
|
|
//注册成功后跳转success.jsp页面
|
|
return "success";
|
|
}
|
|
|
|
@RequestMapping("login")
|
|
public String login(String name,String password,Model model){
|
|
|
|
System.out.println("用户登录:"+name+password);
|
|
|
|
/*Map<String, String> map=new LinkedHashMap<String,String>();
|
|
|
|
map.put("name", user.getName());
|
|
map.put("password", user.getPassword());*/
|
|
|
|
userService.login(name,password);
|
|
|
|
model.addAttribute("msg", "登录成功");
|
|
|
|
return "success";
|
|
}
|
|
}
|