Web. XML configuration Springmvc causes access to the page resource does not exist, jump page appears 404

Source: Internet
Author: User

Web. XML configuration file, configuration SPRINGMVC:

<servlet>
<servlet-name>springMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

<!--set the name and path of the configuration file--
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:springmvc-servlet.xml</param-value>
</init-param>

<!--boot order--
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>/*</url-pattern>//Error
</servlet-mapping>

<!--I thought it was added. * Can be used to indicate all files under the current path, but after the addition of the * number, the Access page resource does not exist, jump page appears 404-->


Controller class Method:......
@RequestMapping ("/checkuser")
Public String checkmemberuser (httpservletrequest req,httpservletresponse Res)
{
System.out.println ("Useraction" +userser.checkuser ()); This will work properly and the console outputs

Return "index";//After adding the * number cannot jump to the index.jsp page
}


The correct one should be:<servlet>
<servlet-name>springMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

<!--set the name and path of the configuration file--
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:springmvc-servlet.xml</param-value>
</init-param>

<!--boot order--
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>/</url-pattern>//Correct, access path cannot add * number
</servlet-mapping>


Remove the * number will be normal operation, you can jump to the specified page.

Web. XML configuration Springmvc causes access to the page resource does not exist, jump page appears 404

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.