No mapping was found for the HTTP request with URI [] in DispatcherServlet named '

In the morning, I already checked most of the answers to this problem ( There is no mapping found for the HTTP request with the URI .... in the DispatcherServlet with the name ), and also ( No mapping was found for the HTTP request with the URI [/ ChickenTest / index] in DispatcherServlet with the name "dispatcherServlet" ), but I still get "There is no mapping for the HTTP request with the URI [/ bmoa-surrounds / bmoa] in the DispatcherServlet with the name" bmoa "", so any help that should be appreciated:

POM:

<dependencies> <!-- Junit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> <!-- Testng --> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.8.5</version> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> </dependency> <!-- Log4j --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.2.6</version> </dependency> <dependency> <groupId>javax.xml</groupId> <artifactId>jaxb-impl</artifactId> <version>2.1</version> </dependency> </dependencies> 

then my web.xml

 <display-name>bmoa-surrounds</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/bmoa-servlet.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>bmoa</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>bmoa</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> 

my spring configuration file

 <context:component-scan base-package="xxxx"/> <context:annotation-config/> <context:spring-configured/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/"/> <property name="suffix" value=".jsp"/> </bean> 

and finally my controller

 @Controller public class BMOAServlet implements HttpRequestHandler { /** * */ @RequestMapping("/bmoa-surrounds/bmoa") public void handleRequest(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { response.getWriter().write("result=" + handleIncomingMessage(request)); } 

I call "http: // localhost: 8080 / bmoa-surrounds / bmoa? Juan = 9898", but I still don't get No matching found for the HTTP request with URI [/ bmoa-surrounds / bmoa] in a DispatcherServlet named "bmoa", any ideas? my env is java6 deployment in jboss

also sure beans are loaded beign, i got this in server log

 12:34:06,671 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-5) Pre-instantiating singletons in org.s pringframework.beans.factory.support.DefaultListableBeanFactory@ 57ffa0: defining beans [BMOABussinesDelegate,properties,BMOAServlet,.........]; parent: org.s pringframework.beans.factory.support.DefaultListableBeanFactory@ 122d7c6 

as well as this

 12:34:06,753 INFO [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-5) Mapped URL path [/bmoa-surrounds/bmoa] onto handler 'BMOAServlet' 12:34:06,754 INFO [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-5) Mapped URL path [/bmoa-surrounds/bmoa.*] onto handler 'BMOAServlet' 12:34:06,755 INFO [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-5) Mapped URL path [/bmoa-surrounds/bmoa/] onto handler 'BMOAServlet' 

doesnt the latter mean that mappings are loading ?? please, help; (

+5
source share
3 answers

I feel really dumb right now ... first (and thanks for the Angad hint), the url pattern was wrong, it should point to the servlet, the bean loaded as well was BMOAServlet instead of bmoa, so when I changed url-patter no bmoa, I I managed to see an error, at the end my web.xml should look like this:

 <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/bmoa-servlet.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>bmoa</servlet-name> <servlet-class>org.springframework.web.context.support.HttpRequestHandlerServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>bmoa</servlet-name> <url-pattern>/bmoa</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> 

and bean class:

 @Controller("bmoa") public class BMOAServlet implements HttpRequestHandler { /** * */ @RequestMapping("/bmoa-surrounds/bmoa") public void handleRequest(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { response.getWriter().write("result=" + handleIncomingMessage(request)); } 

Now everything works smoothly, I also changed the servlet class as follows:

 <servlet> <servlet-name>bmoa</servlet-name> <servlet-class>org.springframework.web.context.support.HttpRequestHandlerServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> 
+2
source

Check this configuration file: src \ main \ webapp \ WEB-INF \ spring \ appServlet \ controllers.xml

the content is similar to:

 <context:component-scan base-package="org.springframework.samples.mvc" /> 

is your controller in "org.springframework.samples.mvc"?

0
source

In pom.xml, make sure the packaging is set to war as <packaging>war</packaging> , and not in jar or anything else.

-1
source

Source: https://habr.com/ru/post/1205383/


All Articles