spring mvc page not found no mapping found for http request with uri

我這裏的報錯實際情況是:

14:02:15,736 WARN  [PageNotFound] No mapping found for HTTP request with URI [/spring3MVC/abc/index.do] in DispatcherServlet with name 'spring3MVC'

其中,[spring3MVC/abc/index.do]是我請求的路徑,就我現在的項目,我的請求路徑是:

http://localhost:8080/spring3MVC/abc/index.do


spring3MVC是我的項目名,abc是action的註解用的,index是方法的註解

@Controller
@RequestMapping("/abc")
public class ZhujieRequestController  {

    protected final transient Log log = LogFactory.getLog(ZhujieRequestController.class);

    @RequestMapping("/index")
    public String index() {
        return "hello";
    }

}

其它的配置文件,比如web.xml和一些jdbc連接的我就不說了,就說核心xml文件:spring3MVC-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:tx="http://www.springframework.org/schema/tx"
	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/tx   
    http://www.springframework.org/schema/tx/spring-tx-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.1.xsd">




	<!--自動掃描的包名 -->
	<context:component-scan base-package="com.ideawu" />

	<!-- 默認的註解映射的支持 -->
	<!-- <mvc:annotation-driven /> -->

	<!-- 視圖解釋類 -->
	<bean id="viewResolver"
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/" />
		<property name="suffix" value=".jsp" />
		<!--
			可爲空,方便實現自已的依據擴展名來選擇視圖解釋類的邏輯
		-->
		<property name="viewClass"
			value="org.springframework.web.servlet.view.JstlView" />
	</bean>

	
	

	<!-- 通過註解請求action裏面的方法-->
	<bean id="annotationHandlerMapping"
		class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
		<property name="order" value="0" />
		<property name="useDefaultSuffixPattern" value="false" /><!--請注意這裏,value="false",就因爲這個false,我從早上8點,弄到下午2點-->
		
	</bean>


	
	<bean
		class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
</beans>	
基本配置就是這樣,服務重啓了好多變,總是不行,後來,我把
<property name="useDefaultSuffixPattern" value="false" />
的value改爲true,就正常了。 哎,我也是剛學,碰到這個問題。   還好運氣好,搞定了

發佈了33 篇原創文章 · 獲贊 1 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章