About Spring MVC in the address bar access/WEB-INF under the. jsp, mvcweb-inf

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.