Error 404-Not Found Spring MVC application

Asked

Viewed 667 times

1

I’m getting the bug

Error 404-Not Found: The server has not found Anything matching the Request-URI

when trying to access any url of my application, the strange thing is that the page index.jsp works normally, including loading Resources that define in springmv-servlet.xml.

Project structure:

+ siebelutilities
+-- WebContent/
  +-- META-INF/
  +-- resources/
  +-- WEB-INF/
    +-- jsp/
     +-- lib/
     +-- springmvc-servlet.xml
     +-- tiles.xml
     +-- web.xml
     +-- weblogic.xml

web xml.:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
    <display-name>siebelutilities</display-name>
    <servlet>
        <servlet-name>springmvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    <listener>
        <listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>Tiles Dispatch Servlet</servlet-name>
        <servlet-class>org.apache.tiles.web.util.TilesDispatchServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Tiles Dispatch Servlet</servlet-name>
        <url-pattern>*.tiles</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

springmvc-Servlet.xml:

<?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:p="http://www.springframework.org/schema/p"  
    xmlns:context="http://www.springframework.org/schema/context" 
    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.1.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.1.xsd 
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">

    <context:component-scan base-package="com.eduardo.siebutil.service" />

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <mvc:resources mapping="/resources/**" location="/resources/" cache-period="31556926" />
    <mvc:annotation-driven />
</beans>

I’m the @RequestMapping thus:

@RequestMapping(value = "/account/create")
public ModelAndView create() {
    ModelAndView model = new ModelAndView("/account/create");

    return model;
}
  • 1

    Putting a debug in the line of the model Modelandview comes to pass or not? My question is whether you are not able to find the JSP file or the method, because by the error you are implying that it is not finding a file. The server did not find anything with the URL that was passed. I believe that inside the constructor of Modelandview you need to pass the corresponding file.

  • @Giancarlogiulian he doesn’t even capture the breakpoint, I use this setting of Spring for other projects and works normally.

1 answer

1


Solved, but in a strange way, I detected a import of a lib that I did not possess in my classpath and the eclipse didn’t accuse me of that mistake (The import xxx cannot be resolved). When making a change to pom.xml I did an update of the Maven project and it was detected, so I did a Project > Clean and my pages are being called.

  • Thanks for your return, does not have a setting in your Eclipse that is ignoring this error?

  • 1

    At first I’m not seeing anything, @Giancarlogiulian. I thought I had disabled the Eclipse Validation for this project but it’s activated, so I don’t rule out the idea that the problem might be another one that was indirectly solved.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.