SPRINGMVC build Environment times No mapping found for HTTP request with URI [/exam3/welcome] in Dispatcherservlet with name ' Spring2 '

Source: Internet
Author: User

Project is using spring MVC

(1) Access in the browser, the background total error:

Java code
    1. No mapping found for HTTP request with URI [/exam3/welcome] in Dispatcherservlet with name ' spring2 '

Checked the long time, only to find that the controller did not scan.

I am using the annotations.

The spring MVC configuration file is as follows:

XML code
  1. <? XML version= "1.0" encoding="UTF-8"?>
  2. <beans xmlns="Http://www.springframework.org/schema/beans"
  3. xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http// Www.springframework.org/schema/context "
  4. xmlns:aop= "http://www.springframework.org/schema/aop" xmlns:tx= "http://www.springframework.org/ Schema/tx "
  5. xmlns:mvc="Http://www.springframework.org/schema/mvc"
  6. xsi:schemalocation= "Http://www.springframework.org/schema/beans
  7. Http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
  8. Http://www.springframework.org/schema/context
  9. Http://www.springframework.org/schema/context/spring-context-3.2.xsd
  10. Http://www.springframework.org/schema/aop
  11. Http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
  12. Http://www.springframework.org/schema/tx
  13. Http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
  14. Http://www.springframework.org/schema/mvc
  15. Http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd "
  16. >
  17. <!--handlermapping --
  18. <beans
  19. class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
  20. <!--handleradapter --
  21. <beans
  22. class="Org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
  23. <!--viewresolver --
  24. <beans
  25. class="Org.springframework.web.servlet.view.InternalResourceViewResolver">
  26. <property name="Viewclass"
  27. value="Org.springframework.web.servlet.view.JstlView" />
  28. <property name= "prefix" value="/web-inf/jsp/" />
  29. <property name="suffix" value= ". jsp" />
  30. </Bean>
  31. <mvc:annotation-driven />
  32. <!--processor--
  33. <!--<bean name= "/hello" class= "Com.mvc.jn.controller.HelloWorldController"/>--
  34. <context:component-scan base-package="com"/>
  35. </Beans>

The controller's directory structure is as follows:



(2) After the problem is resolved, the error is:

No mapping found for HTTP request with URI [/exam3/web-inf/jsp/welcome.jsp] in Dispatcherservlet with name ' Spring2 '

The result is that the Web. XML is configured with a problem, the following is problematic:

XML code
  1. <servlet>
  2. <servlet-name>spring2</servlet-name>
  3. <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class >
  4. <load-on-startup>1</load-on-startup>
  5. </servlet>
  6. <servlet-mapping>
  7. <servlet-name>spring2</servlet-name>
  8. <url-pattern>/*</url-pattern>
  9. </servlet-mapping>

Workaround: Change Url-pattern from/* To/

SPRINGMVC build Environment times No mapping found for HTTP request with URI [/exam3/welcome] in Dispatcherservlet with name ' Spring2 '

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.