About Spring MVC in the address bar access/WEB-INF under the. jsp, mvcweb-inf
WEB-INF is the protection of resources, direct access to the WEB-INF directory in the address bar under the page, will display 404, on why to put the page under the WEB-INF, can be self Baidu
Here I access the page under the WEB-INF directory with SpringMVC, assuming there is now an index. jsp page under the WEB-INF
① In the Spring-mvc.xml configuration file, configure the view parser
Prefix indicates the prefix, and suffix indicates the suffix. Index. jsp under/WEB-INF/view
② Compile the corresponding Controller, that is, the page you want to access. SpringMVC can help you allocate the corresponding page.
1 package com. luo. ssm. controller; 2 3 import org. springframework. stereotype. controller; 4 import org. springframework. web. bind. annotation. requestMapping; 5 import org. springframework. web. bind. annotation. requestMethod; 6 7 @ Controller 8 @ RequestMapping (value = "/user") 9 public class LoginController () {10 11 @ RequestMapping (value = "/login ") 12 public String login () {13 return "login"; 14} 15}
Eg: The method name here must be the same as the page name
Now you can use http: // localhost: 8080/xxxx/user/login to access the page (XXX is your project name and there is no. jsp suffix after login)