问题描述
给出web.xmldispatcher-servlet.xml的配置信息<?xmlversion="1.0"encoding="UTF-8"?><web-appxmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"version="3.0"metadata-complete="true"><display-name>dispatcher</display-name><servlet><servlet-name>dispatcher</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>dispatcher</servlet-name><url-pattern>/</url-pattern></servlet-mapping><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list></web-app>
<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.0.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd"><!--使Spring支持自动检测组件,如注解的Controller--><context:component-scanbase-package="com.minx.crm.web.controller"></context:component-scan><context:component-scanbase-package="com.minx.crm.web"/><beanid="viewResolver"class="org.springframework.web.servlet.view.InternalResourceViewResolver"p:prefix="/WEB-INF/"p:suffix=".jsp"/></beans>
packagecom.minx.crm.web.controller;importorg.springframework.stereotype.Controller;importorg.springframework.web.bind.annotation.RequestMapping;@Controller@RequestMapping(value="index")publicclassIndexController{@RequestMapping(value="say")publicStringsayHello(){return"index";}}
所有的信息都在上面Spring已经放在tomcat的webapps文件夹下面但是访问http://localhost:8080/Spring/index/say就是404单独访问http://localhost:8080/Spring/index.jsp是可以的大神帮忙看看是哪里出问题了啊
解决方案
解决方案二:
@RequestMapping(value="/index/*")
解决方案三:
加上/index/say试试看
解决方案四:
@RequestMapping(value="index")改成@RequestMapping(value="/index")
解决方案五:
引用1楼longtian1213的回复:
@RequestMapping(value="/index/*")
不行啊
解决方案六:
引用3楼a470577391的回复:
@RequestMapping(value="index")改成@RequestMapping(value="/index")
试了也不行我现在目录结构是这样的我想问WebContent/WEB-INF/web.xml这个文件tomcat能解析到吗
解决方案七:
补充一下:tomcat启动报错了什么原因呢七月30,20149:45:12上午org.apache.catalina.core.AprLifecycleListenerinit信息:TheAPRbasedApacheTomcatNativelibrarywhichallowsoptimalperformanceinproductionenvironmentswasnotfoundonthejava.library.path:C:ProgramFilesJavajre7bin;C:WindowsSunJavabin;C:Windowssystem32;C:Windows;C:/ProgramFiles/Java/jre7/bin/client;C:/ProgramFiles/Java/jre7/bin;C:/ProgramFiles/Java/jre7/lib/i386;C:Perlsitebin;C:Perlbin;C:ProgramFilesInteliCLSClient;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:ProgramFilesIntelIntel(R)ManagementEngineComponentsDAL;C:ProgramFilesIntelIntel(R)ManagementEngineComponentsIPT;C:ProgramFilesTortoiseSVNbin;C:ProgramFilesMicrosoftSQLServer100ToolsBinn;C:ProgramFilesMicrosoftSQLServer100DTSBinn;C:ProgramFilesMicrosoftWebPlatformInstaller;C:ProgramFilesMicrosoftASP.NETASP.NETWebPagesv1.0;C:ProgramFilesWindowsKits8.0WindowsPerformanceToolkit;C:ProgramFilesMicrosoftSQLServer110ToolsBinn;E:wampbinphpphp5.3.13;E:javajdk1.7bin;;E:eclipse;;.七月30,20149:45:12上午org.apache.coyote.AbstractProtocolinit信息:InitializingProtocolHandler["http-bio-8080"]七月30,20149:45:12上午org.apache.coyote.AbstractProtocolinit信息:InitializingProtocolHandler["ajp-bio-8009"]七月30,20149:45:12上午org.apache.catalina.startup.Catalinaload信息:Initializationprocessedin496ms七月30,20149:45:12上午org.apache.catalina.core.StandardServicestartInternal信息:StartingserviceCatalina七月30,20149:45:12上午org.apache.catalina.core.StandardEnginestartInternal信息:StartingServletEngine:ApacheTomcat/7.0.29七月30,20149:45:12上午org.apache.catalina.startup.HostConfigdeployDirectory信息:DeployingwebapplicationdirectoryE:javatomcatwebappsbaremvc七月30,20149:45:14上午org.apache.catalina.core.ContainerBaseaddChildInternal严重:ContainerBase.addChild:start:org.apache.catalina.LifecycleException:Failedtostartcomponent[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/baremvc]]atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100)atorg.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618)atjava.util.concurrent.Executors$RunnableAdapter.call(UnknownSource)atjava.util.concurrent.FutureTask.run(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor.runWorker(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(UnknownSource)atjava.lang.Thread.run(UnknownSource)Causedby:java.lang.NoClassDefFoundError:Lorg/apache/commons/logging/Log;atjava.lang.Class.getDeclaredFields0(NativeMethod)atjava.lang.Class.privateGetDeclaredFields(UnknownSource)atjava.lang.Class.getDeclaredFields(UnknownSource)atorg.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:87)atorg.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261)atorg.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:140)atorg.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:67)atorg.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:382)atorg.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:858)atorg.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:346)atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)atorg.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)atorg.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)...10moreCausedby:java.lang.ClassNotFoundException:org.apache.commons.logging.Logatorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)atorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)...24more七月30,20149:45:14上午org.apache.catalina.startup.HostConfigdeployDirectory严重:ErrordeployingwebapplicationdirectoryE:javatomcatwebappsbaremvcjava.lang.IllegalStateException:ContainerBase.addChild:start:org.apache.catalina.LifecycleException:Failedtostartcomponent[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/baremvc]]atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100)atorg.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618)atjava.util.concurrent.Executors$RunnableAdapter.call(UnknownSource)atjava.util.concurrent.FutureTask.run(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor.runWorker(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(UnknownSource)atjava.lang.Thread.run(UnknownSource)七月30,20149:45:14上午org.apache.catalina.startup.HostConfigdeployDirectory信息:DeployingwebapplicationdirectoryE:javatomcatwebappsdocs七月30,20149:45:14上午org.apache.catalina.startup.HostConfigdeployDirectory信息:DeployingwebapplicationdirectoryE:javatomcatwebappsexamples七月30,20149:45:14上午org.apache.catalina.core.ApplicationContextlog信息:ContextListener:contextInitialized()七月30,20149:45:14上午org.apache.catalina.core.ApplicationContextlog信息:SessionListener:contextInitialized()七月30,20149:45:14上午org.apache.catalina.core.ApplicationContextlog信息:ContextListener:attributeAdded('org.apache.jasper.compiler.TldLocationsCache','org.apache.jasper.compiler.TldLocationsCache@19094a8')七月30,20149:45:14上午org.apache.catalina.startup.HostConfigdeployDirectory信息:DeployingwebapplicationdirectoryE:javatomcatwebappshost-manager七月30,20149:45:14上午org.apache.catalina.startup.HostConfigdeployDirectory信息:DeployingwebapplicationdirectoryE:javatomcatwebappsmanager七月30,20149:45:14上午org.apache.catalina.startup.HostConfigdeployDirectory信息:DeployingwebapplicationdirectoryE:javatomcatwebappsROOT七月30,20149:45:14上午org.apache.coyote.AbstractProtocolstart信息:StartingProtocolHandler["http-bio-8080"]七月30,20149:45:14上午org.apache.coyote.AbstractProtocolstart信息:StartingProtocolHandler["ajp-bio-8009"]七月30,20149:45:14上午org.apache.catalina.startup.Catalinastart信息:Serverstartupin2192ms七月30,20149:46:04上午org.apache.catalina.startup.HostConfigdeployDirectory信息:DeployingwebapplicationdirectoryE:javatomcatwebappsSpring
解决方案八:
引用6楼yolandafans的回复:
补充一下:tomcat启动报错了什么原因呢七月30,20149:45:12上午org.apache.catalina.core.AprLifecycleListenerinit信息:TheAPRbasedApacheTomcatNativelibrarywhichallowsoptimalperformanceinproductionenvironmentswasnotfoundonthejava.library.path:C:ProgramFilesJavajre7bin;C:WindowsSunJavabin;C:Windowssystem32;C:Windows;C:/ProgramFiles/Java/jre7/bin/client;C:/ProgramFiles/Java/jre7/bin;C:/ProgramFiles/Java/jre7/lib/i386;C:Perlsitebin;C:Perlbin;C:ProgramFilesInteliCLSClient;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:ProgramFilesIntelIntel(R)ManagementEngineComponentsDAL;C:ProgramFilesIntelIntel(R)ManagementEngineComponentsIPT;C:ProgramFilesTortoiseSVNbin;C:ProgramFilesMicrosoftSQLServer100ToolsBinn;C:ProgramFilesMicrosoftSQLServer100DTSBinn;C:ProgramFilesMicrosoftWebPlatformInstaller;C:ProgramFilesMicrosoftASP.NETASP.NETWebPagesv1.0;C:ProgramFilesWindowsKits8.0WindowsPerformanceToolkit;C:ProgramFilesMicrosoftSQLServer110ToolsBinn;E:wampbinphpphp5.3.13;E:javajdk1.7bin;;E:eclipse;;.七月30,20149:45:12上午org.apache.coyote.AbstractProtocolinit信息:InitializingProtocolHandler["http-bio-8080"]七月30,20149:45:12上午org.apache.coyote.AbstractProtocolinit信息:InitializingProtocolHandler["ajp-bio-8009"]七月30,20149:45:12上午org.apache.catalina.startup.Catalinaload信息:Initializationprocessedin496ms七月30,20149:45:12上午org.apache.catalina.core.StandardServicestartInternal信息:StartingserviceCatalina七月30,20149:45:12上午org.apache.catalina.core.StandardEnginestartInternal信息:StartingServletEngine:ApacheTomcat/7.0.29七月30,20149:45:12上午org.apache.catalina.startup.HostConfigdeployDirectory信息:DeployingwebapplicationdirectoryE:javatomcatwebappsbaremvc七月30,20149:45:14上午org.apache.catalina.core.ContainerBaseaddChildInternal严重:ContainerBase.addChild:start:org.apache.catalina.LifecycleException:Failedtostartcomponent[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/baremvc]]atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100)atorg.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618)atjava.util.concurrent.Executors$RunnableAdapter.call(UnknownSource)atjava.util.concurrent.FutureTask.run(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor.runWorker(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(UnknownSource)atjava.lang.Thread.run(UnknownSource)Causedby:java.lang.NoClassDefFoundError:Lorg/apache/commons/logging/Log;atjava.lang.Class.getDeclaredFields0(NativeMethod)atjava.lang.Class.privateGetDeclaredFields(UnknownSource)atjava.lang.Class.getDeclaredFields(UnknownSource)atorg.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:87)atorg.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261)atorg.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:140)atorg.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:67)atorg.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:382)atorg.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:858)atorg.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:346)atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)atorg.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)atorg.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)...10moreCausedby:java.lang.ClassNotFoundException:org.apache.commons.logging.Logatorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)atorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)...24more七月30,20149:45:14上午org.apache.catalina.startup.HostConfigdeployDirectory严重:ErrordeployingwebapplicationdirectoryE:javatomcatwebappsbaremvcjava.lang.IllegalStateException:ContainerBase.addChild:start:org.apache.catalina.LifecycleException:Failedtostartcomponent[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/baremvc]]atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100)atorg.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618)atjava.util.concurrent.Executors$RunnableAdapter.call(UnknownSource)atjava.util.concurrent.FutureTask.run(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor.runWorker(UnknownSource)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(UnknownSource)atjava.lang.Thread.run(UnknownSource)七月30,20149:45:14上午org.apache.catalina.startup.HostConfigdeployDirectory信息:DeployingwebapplicationdirectoryE:javatomcatwebappsdocs七月30,20149:45:14上午org.apache.catalina.startup.HostConfigdeployDirectory信息:DeployingwebapplicationdirectoryE:javatomcatwebappsexamples七月30,20149:45:14上午org.apache.catalina.core.ApplicationContextlog信息:ContextListener:contextInitialized()七月30,20149:45:14上午org.apache.catalina.core.ApplicationContextlog信息:SessionListener:contextInitialized()七月30,20149:45:14上午org.apache.catalina.core.ApplicationContextlog信息:ContextListener:attributeAdded('org.apache.jasper.compiler.TldLocationsCache','org.apache.jasper.compiler.TldLocationsCache@19094a8')七月30,20149:45:14上午org.apache.catalina.startup.HostConfigdeployDirectory信息:DeployingwebapplicationdirectoryE:javatomcatwebappshost-manager七月30,20149:45:14上午org.apache.catalina.startup.HostConfigdeployDirectory信息:DeployingwebapplicationdirectoryE:javatomcatwebappsmanager七月30,20149:45:14上午org.apache.catalina.startup.HostConfigdeployDirectory信息:DeployingwebapplicationdirectoryE:javatomcatwebappsROOT七月30,20149:45:14上午org.apache.coyote.AbstractProtocolstart信息:StartingProtocolHandler["http-bio-8080"]七月30,20149:45:14上午org.apache.coyote.AbstractProtocolstart信息:StartingProtocolHandler["ajp-bio-8009"]七月30,20149:45:14上午org.apache.catalina.startup.Catalinastart信息:Serverstartupin2192ms七月30,20149:46:04上午org.apache.catalina.startup.HostConfigdeployDirectory信息:DeployingwebapplicationdirectoryE:javatomcatwebappsSpring
你项目出异常了,没部署成功,当然不行了!commons-logging和commons-logging-api两个jar包你有加没?
解决方案九:
10:28:39.623[http-bio-8080-exec-5]WARNo.s.web.servlet.PageNotFound-NomappingfoundforHTTPrequestwithURI[/baremvc/]inDispatcherServletwithname'appServlet'10:28:39.623[http-bio-8080-exec-5]DEBUGo.s.web.servlet.DispatcherServlet-Successfullycompletedrequest10:31:02.045[http-bio-8080-exec-8]DEBUGo.s.web.servlet.DispatcherServlet-DispatcherServletwithname'appServlet'processingGETrequestfor[/baremvc/index/home]10:31:02.046[http-bio-8080-exec-8]DEBUGo.s.w.s.m.m.a.RequestMappingHandlerMapping-Lookinguphandlermethodforpath/index/home10:31:02.046[http-bio-8080-exec-8]DEBUGo.s.w.s.m.m.a.RequestMappingHandlerMapping-Didnotfindhandlermethodfor[/index/home]10:31:02.046[http-bio-8080-exec-8]WARNo.s.web.servlet.PageNotFound-NomappingfoundforHTTPrequestwithURI[/baremvc/index/home]inDispatcherServletwithname'appServlet'10:31:02.046[http-bio-8080-exec-8]DEBUGo.s.web.servlet.DispatcherServlet-Successfullycompletedrequest10:34:35.015[http-bio-8080-exec-1]DEBUGo.s.web.servlet.DispatcherServlet-DispatcherServletwithname'appServlet'processingGETrequestfor[/baremvc/index/home]10:34:35.016[http-bio-8080-exec-1]DEBUGo.s.w.s.m.m.a.RequestMappingHandlerMapping-Lookinguphandlermethodforpath/index/home10:34:35.016[http-bio-8080-exec-1]DEBUGo.s.w.s.m.m.a.RequestMappingHandlerMapping-Didnotfindhandlermethodfor[/index/home]10:34:35.016[http-bio-8080-exec-1]WARNo.s.web.servlet.PageNotFound-NomappingfoundforHTTPrequestwithURI[/baremvc/index/home]inDispatcherServletwithname'appServlet'10:34:35.016[http-bio-8080-exec-1]DEBUGo.s.web.servlet.DispatcherServlet-Successfullycompletedrequest10:34:35.175[http-bio-8080-exec-1]DEBUGo.s.web.servlet.DispatcherServlet-DispatcherServletwithname'appServlet'processingGETrequestfor[/baremvc/index/home]10:34:35.175[http-bio-8080-exec-1]DEBUGo.s.w.s.m.m.a.RequestMappingHandlerMapping-Lookinguphandlermethodforpath/index/home10:34:35.175[http-bio-8080-exec-1]DEBUGo.s.w.s.m.m.a.RequestMappingHandlerMapping-Didnotfindhandlermethodfor[/index/home]10:34:35.176[http-bio-8080-exec-1]WARNo.s.web.servlet.PageNotFound-NomappingfoundforHTTPrequestwithURI[/baremvc/index/home]inDispatcherServletwithname'appServlet'10:34:35.176[http-bio-8080-exec-1]DEBUGo.s.web.servlet.DispatcherServlet-Successfullycompletedrequest现在出这个错了
解决方案十:
你用了注解,要注册注解处理器<mvc:annotation-driven/>
解决方案十一:
引用9楼longtian1213的回复:
你用了注解,要注册注解处理器<mvc:annotation-driven/>
刚接触不太明白我配置文件应该怎么写呢
解决方案十二:
引用10楼yolandafans的回复:
Quote: 引用9楼longtian1213的回复:
你用了注解,要注册注解处理器<mvc:annotation-driven/>刚接触不太明白我配置文件应该怎么写呢
SpringMVC3.0的配置文件网上有很多,找个照着写就写了
解决方案十三:
引用11楼longtian1213的回复:
Quote: 引用10楼yolandafans的回复:
Quote: 引用9楼longtian1213的回复:
你用了注解,要注册注解处理器<mvc:annotation-driven/>刚接触不太明白我配置文件应该怎么写呢
SpringMVC3.0的配置文件网上有很多,找个照着写就写了
我贴出来的就是仿照写的但是问题出在哪不清楚
解决方案十四:
在你的dispatcher-servlet里面加一句<mvc:annotation-driven/>而且你看这个错误来说应该还不只是这个问题
解决方案十五:
引用12楼yolandafans的回复:
Quote: 引用11楼longtian1213的回复:
Quote: 引用10楼yolandafans的回复:
Quote: 引用9楼longtian1213的回复:
你用了注解,要注册注解处理器<mvc:annotation-driven/>刚接触不太明白我配置文件应该怎么写呢
SpringMVC3.0的配置文件网上有很多,找个照着写就写了
我贴出来的就是仿照写的但是问题出在哪不清楚
你是用的注解,要加上<mvc:annotation-driven/>或者用这两个<beanclass="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/><beanclass="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>让注解起作用
解决方案:
引用13楼SDstyle的回复:
在你的dispatcher-servlet里面加一句<mvc:annotation-driven/>而且你看这个错误来说应该还不只是这个问题
<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context"xmlns:p="http://www.springframework.org/schema/p"xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:util="http://www.springframework.org/schema/util"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-4.0.xsdhttp://www.springframework.org/schema/utilhttp://www.springframework.org/schema/util/spring-util-3.1.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-4.0.xsd"><!--DispatcherServletContext:definesthisservlet'srequest-processinginfrastructure--><!--Scanswithinthebasepackageoftheapplicationfor@Componentstoconfigureasbeans--><!--@Controller,@Service,@Configuration,etc.--><!--注解扫描包--><context:component-scanbase-package="com.controller"></context:component-scan><context:component-scanbase-package="com"/><context:annotation-config/><!--EnablestheSpringMVC@Controllerprogrammingmodel--><mvc:annotation-driven/><beanid="viewResolver"class="org.springframework.web.servlet.view.InternalResourceViewResolver"><propertyname="prefix"value="/WEB-INF/views/"></property><propertyname="suffix"value=".jsp"></property></bean></beans>
我现在配置是这样的tomcat的错误log是:13:50:52.054[http-bio-8080-exec-6]DEBUGo.s.web.servlet.DispatcherServlet-DispatcherServletwithname'appServlet'processingGETrequestfor[/baremvc/index/home]13:50:52.054[http-bio-8080-exec-6]DEBUGo.s.w.s.m.m.a.RequestMappingHandlerMapping-Lookinguphandlermethodforpath/index/home13:50:52.054[http-bio-8080-exec-6]DEBUGo.s.w.s.m.m.a.RequestMappingHandlerMapping-Didnotfindhandlermethodfor[/index/home]13:50:52.054[http-bio-8080-exec-6]WARNo.s.web.servlet.PageNotFound-NomappingfoundforHTTPrequestwithURI[/baremvc/index/home]inDispatcherServletwithname'appServlet'13:50:52.054[http-bio-8080-exec-6]DEBUGo.s.web.servlet.DispatcherServlet-Successfullycompletedrequestpackagecom.controller;importorg.springframework.stereotype.Controller;importorg.springframework.web.bind.annotation.RequestMapping;/***Handlesrequestsfortheapplicationhomepage.*/@Controller@RequestMapping("/index")publicclassHomeController{@RequestMapping("/home")publicStringhome(){//System.out.println("HomeController:Passingthrough...");//return"xixi";return"home";}}
解决方案:
'appServlet'这个是哪里定义的
解决方案:
解决方案:
引用16楼longtian1213的回复:
'appServlet'这个是哪里定义的
<?xmlversion="1.0"encoding="UTF-8"?><web-appversion="2.5"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/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"><welcome-file-list><welcome-file>index.html</welcome-file><welcome-file>index.htm</welcome-file><welcome-file>index.jsp</welcome-file><welcome-file>default.html</welcome-file><welcome-file>default.htm</welcome-file><welcome-file>default.jsp</welcome-file></welcome-file-list><!--Processesapplicationrequests--><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></web-app>
WEB.XML里面定义的
解决方案:
引用18楼yolandafans的回复:
Quote: 引用16楼longtian1213的回复:
'appServlet'这个是哪里定义的<?xmlversion="1.0"encoding="UTF-8"?><web-appversion="2.5"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/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"><welcome-file-list><welcome-file>index.html</welcome-file><welcome-file>index.htm</welcome-file><welcome-file>index.jsp</welcome-file><welcome-file>default.html</welcome-file><welcome-file>default.htm</welcome-file><welcome-file>default.jsp</welcome-file></welcome-file-list><!--Processesapplicationrequests--><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></web-app>
WEB.XML里面定义的
我看你的截图,你有个dispatcher-servlet.xml文件吧,和servlet-context.xml的内容是什么
解决方案:
引用3楼a470577391的回复:
@RequestMapping(value="index")改成@RequestMapping(value="/index")
正解
解决方案:
该回复于2014-07-30 21:22:51被版主删除
解决方案:
mark,study