DispatcherServlet noHandlerFound

web.xml
<?xml version="1.0" encoding="UTF-8"?>

<!-- Erp -->


contextConfigLocation
classpath*:spring/applicationContext-*.xml


characterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter

encoding
UTF-8


forceEncoding
true



characterEncodingFilter
/*


org.springframework.web.context.ContextLoaderListener


org.springframework.web.util.IntrospectorCleanupListener


springmvc
org.springframework.web.servlet.DispatcherServlet

contextConfigLocation
classpath*:spring/springmvc-servlet.xml

1


springmvc
/


30


index


403
/error/403.html


404
/error/404.html


500
/error/500.html

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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"

default-autowire="byName" default-lazy-init="false">

<!-- 配置静态文件请求,不经过Spring Dispatcher Servlet
(PS:该标签是spring 3.0.4新增的,而目前还没有相应的schema,因此编辑器里面会提示mvc:resource标签未定义) -->
<mvc:resources location="/js/" mapping="/js/**/*"/>
<mvc:resources location="/css/" mapping="/css/**/*"/>
<mvc:resources location="/image/" mapping="/image/**/*"/>
<mvc:resources location="/error/" mapping="/error/**/*"/>
<mvc:resources location="/upload/" mapping="/upload/**/*"/>
<mvc:resources location="/widgets/" mapping="/widgets/**/*"/>
<mvc:resources location="/robots.txt" mapping="/robots.txt"/>
<mvc:resources location="/favicon.ico" mapping="/favicon.ico"/>

<!-- 自动搜索指定包目录下的,@Controller,@Component标注的Bean类 
    context:component-scan 会隐式地注册AutowiredAnnotationBeanPostProcessor、
    CommonAnnotationBeanPostProcessor,所以在某种程度上可以把context:annotation-config移除掉
-->

<context:component-scan base-package="java" use-default-filters="false">
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>   

<bean class="org.springframework.web.servlet.mvc.annotation.annotationMethodHandlerAdapter">
    <property name="messageConverters">
        <list>
            <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                <property name="supportedMediaTypes">
                    <list>
                        <value>text/plain;charset=UTF-8</value>
                    </list>
                </property>
            </bean>
        </list>
    </property>
</bean>

<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"></bean>

<bean id="freemarkerConfiguration" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <property name="location" value="classpath:config/ftl.properties"/>
</bean>

<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
    <property name="templateLoaderPath" value="/WEB-INF/ftl/" />
    <property name="freemarkerSettings" ref="freemarkerConfiguration"/>

</bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
    <property name="order" value="1"/>
    <property name="prefix" value=""/>
    <property name="suffix" value=".ftl"/>
    <property name="contentType" value="text/html;charset=utf-8"/>
    <property name="cache" value="true" />

    <property name="exposeSpringMacroHelpers" value="true" />
    <property name="requestContextAttribute" value="request" />

    <property name="exposeRequestAttributes" value="true" />
    <property name="exposeSessionAttributes" value="true" />

    <property name="viewClass">
        <value>org.springframework.web.servlet.view.freemarker.FreeMarkerView</value>
    </property>
</bean>

<bean id="jasperResolver" class="org.springframework.web.servlet.view.jasperreports.JasperReportsViewResolver">
    <property name="order" value="2" />
    <property name="prefix" value="/WEB-INF/jasper/" />
    <property name="suffix" value=".jasper" />

    <property name="viewClass" value="org.springframework.web.servlet.view.jasperreports.JasperReportsMultiFormatView" />

    <property name="exporterParameters">
        <map>
            <entry key="net.sf.jasperreports.engine.JRExporterParameter.CHARACTER_ENCODING">
                <value>utf-8</value>
            </entry>
        </map>
    </property>

    <property name="headers">
        <props>
            <prop key="Content-Disposition">attachment;</prop>
        </props>
    </property>

</bean>

<bean class="org.springframework.web.servlet.view.XmlViewResolver"
        p:location="/WEB-INF/jasper/jasper-views.xml" p:order="0"
></bean>


console:
信息: Server startup in 4949 ms
六月 07, 2017 11:43:24 上午 org.springframework.web.servlet.DispatcherServlet noHandlerFound
警告: No mapping found for HTTP request with URI [/Erp/] in DispatcherServlet with name 'springmvc'
六月 07, 2017 11:43:24 上午 org.springframework.web.servlet.DispatcherServlet noHandlerFound
警告: No mapping found for HTTP request with URI [/Erp/error/404.html] in DispatcherServlet with name 'springmvc'![图片说明](https://img-ask.csdn.net/upload/201706/07/1496807975_868152.png)图片说明

是没加 @Service @comtroller的原因么

有加Controller

package java.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class Index extends DefaultController{
//@RequestMapping("/index")
@RequestMapping(value={"/index"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
//@RequestMapping(value="/index")
public String index(ModelMap modelMap){
return "/index";
}
}