Project is using spring MVC
(1) Access in the browser, the background total error:
Java code
- 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
- <? XML version= "1.0" encoding="UTF-8"?>
- <beans xmlns="Http://www.springframework.org/schema/beans"
- xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http// Www.springframework.org/schema/context "
- xmlns:aop= "http://www.springframework.org/schema/aop" xmlns:tx= "http://www.springframework.org/ Schema/tx "
- xmlns:mvc="Http://www.springframework.org/schema/mvc"
- xsi:schemalocation= "Http://www.springframework.org/schema/beans
- Http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
- Http://www.springframework.org/schema/context
- Http://www.springframework.org/schema/context/spring-context-3.2.xsd
- Http://www.springframework.org/schema/aop
- Http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
- Http://www.springframework.org/schema/tx
- Http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
- Http://www.springframework.org/schema/mvc
- Http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd "
- >
- <!--handlermapping --
- <beans
- class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
- <!--handleradapter --
- <beans
- class="Org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
- <!--viewresolver --
- <beans
- class="Org.springframework.web.servlet.view.InternalResourceViewResolver">
- <property name="Viewclass"
- value="Org.springframework.web.servlet.view.JstlView" />
- <property name= "prefix" value="/web-inf/jsp/" />
- <property name="suffix" value= ". jsp" />
- </Bean>
- <mvc:annotation-driven />
- <!--processor--
- <!--<bean name= "/hello" class= "Com.mvc.jn.controller.HelloWorldController"/>--
- <context:component-scan base-package="com"/>
- </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
- <servlet>
- <servlet-name>spring2</servlet-name>
- <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class >
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>spring2</servlet-name>
- <url-pattern>/*</url-pattern>
- </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 '