org.springframework.web.servlet.DispatcherServlet noHandlerFound


页面显示

org.springframework.web.servlet.DispatcherServlet noHandlerFound_第1张图片

后台显示

org.springframework.web.servlet.DispatcherServlet noHandlerFound

 No mapping found for HTTP request with URI [/springmvc_first/jsp/items/queryItem.action] in DispatcherServlet with name 'springmvc'

访问的地址是:http://127.0.0.1/springmvc_first/jsp/items/queryItem.action

项目结构

org.springframework.web.servlet.DispatcherServlet noHandlerFound_第2张图片

前端控制器的配置


<web-app version="3.0"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    
  <servlet>
    <servlet-name>springmvcservlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServletservlet-class>
    
    <init-param>
        <param-name>contextConfigLocationparam-name>
        <param-value>classpath:springmvc.xmlparam-value>
    init-param>
  servlet>

  <servlet-mapping>
    <servlet-name>springmvcservlet-name>
    <url-pattern>*.actionurl-pattern>
  servlet-mapping>

web-app>

有人说是*.action的问题

再看一下在spring.xml中配置的Handler

 
        <bean name="/queryItem.action" class="com.ld.springmvc.controller.ItemsController" />


原来是访问路径的问题,配置的是/queryItem.action

访问的路径应该是:127.0.0.1/springmvc_first/queryItem.action

你可能感兴趣的:(springmvc)