SpringMVC controller的注解问题
@Controller@RequestMapping(value="")publicclassUserController{@AutowiredprivateUserSe...
@Controller
@RequestMapping(value = "")
public class UserController {
@Autowired
private UserService userService;
@RequestMapping(value = "login")
public String login() {
System.out.println("this is login method");
List<User> list = userService.getAllUser();
System.out.println(list.size());
return "login";
}
public void setUserService(UserService userService) {
this.userService = userService;
}
}
这段代码,为什么最后访问 Controller的Url 是 localhost:8080/app/user/login.html
而不是 localhost:8080/app/login.html
web。xml 是
<context:component-scan base-package="com.xx.controller"/>
<context:component-scan base-package="com.xx.dao"/> 展开
@RequestMapping(value = "")
public class UserController {
@Autowired
private UserService userService;
@RequestMapping(value = "login")
public String login() {
System.out.println("this is login method");
List<User> list = userService.getAllUser();
System.out.println(list.size());
return "login";
}
public void setUserService(UserService userService) {
this.userService = userService;
}
}
这段代码,为什么最后访问 Controller的Url 是 localhost:8080/app/user/login.html
而不是 localhost:8080/app/login.html
web。xml 是
<context:component-scan base-package="com.xx.controller"/>
<context:component-scan base-package="com.xx.dao"/> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询