samedi 14 mars 2015

org.springframework.web.servlet.PageNotFound noHandlerFound - No mapping found for HTTP request with URI

I know there were a thousand questions like this, but I m blind and can not find error.



mar 14, 2015 8:38:07 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/spring/static/index.html] in DispatcherServlet with name 'appServlet'


servlet-context.xml:



<!-- Handles HTTP GET requests for /resources/** by efficiently serving
up static resources in the ${webappRoot}/resources directory -->

<mvc:resources mapping="/resources/**" location="/resources/" />


<!-- Resolves views selected for rendering by @Controllers to .jsp resources
in the /WEB-INF/views directory -->

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/static/" />
<property name="suffix" value=".html" />
</bean>

<context:component-scan base-package="net.codejava.spring" />


When I was trying launch it with 'normal' .jsp page it is working just fine. Structure:


enter image description here


Main class:



@Controller
public class HomeController {

@Autowired
private UserDAO userDao;

@RequestMapping(value="/")
public ModelAndView home() {
List<User> listUsers = userDao.list();
//ModelAndView model = new ModelAndView("home");
ModelAndView model = new ModelAndView("index");
model.addObject("userList", listUsers);
return model;
}

}


Forgot to add web.xml (but I think it is irrelevant?).



<!-- The definition of the Root Spring Container shared by all Servlets
and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>


<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

Aucun commentaire:

Enregistrer un commentaire