-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserController.java
More file actions
33 lines (25 loc) · 1017 Bytes
/
Copy pathUserController.java
File metadata and controls
33 lines (25 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
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 org.springframework.web.servlet.ModelAndView;
import com.model.User;
import com.service.UserService;
@Controller
@RequestMapping("/user") //http://localhost:8080/ssm_test01/user/hello.do
public class UserController {
@Autowired
private UserService userService;
@RequestMapping(value="/hello") //http://localhost:8080/ssm_test01/user/hello *
public ModelAndView find(User user)
{
System.out.println("userName = "+user.getUserName());
ModelAndView mandv = new ModelAndView();
mandv.setViewName("index");
mandv.addObject("user", user); //addObject后台调用的request.setAttribute
return mandv;
}
}