問題 “No mapping found for HTTP request with URI [/rbiz4/uploadFile.html]” 的解決

來源:互聯網
上載者:User

標籤:

從以前的SpringMVC項目簡化一下做個例子,結果出現了下面的錯誤:

No mapping found for HTTP request with URI [/rbiz4/uploadFile.html]

上面這條資訊是從MyEclipse的控制台裡找出來的。

這條資訊就是指/rbiz4/uploadFile.html這樣的請求找不到對應資訊了,於是依次檢查

1.jsp檔案

2.controller檔案

3.web.xml

發現:

1.jsp檔案form的action就是uploadFile.html,沒錯。

2.controller檔案的RequestMapping是@RequestMapping(value="/uploadFile"),對上了。

3.web.xml裡,將html尾碼的請求交給SpringMVC處理的部分是

    <servlet>
        <servlet-name>spring</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>spring</servlet-name>
        <url-pattern>*.html</url-pattern>
    </servlet-mapping>

三者都沒錯,那麼錯在哪裡呢?

那麼只有一種可能,控制器類SpringMVC不認識,於是開啟spring-servlet.xml,發現有條控制器的資訊

    <!-- scan the classed marked with @Controller annotation under the package com.controller -->
    <context:component-scan base-package="com.company.controller" />

也該修改成實際的

    <!-- scan the classed marked with @Controller annotation under the package com.controller -->
    <context:component-scan base-package="com.cp.ctrl" />

這樣,控制器類才會被SpringMVC識別,不是類名前有個@Controller註解就可以了。

2016年8月1日23:46:46

 

問題 “No mapping found for HTTP request with URI [/rbiz4/uploadFile.html]” 的解決

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.