關(guān)于springmvc報錯404的問題
最近初學(xué)springmvc,做了一個簡單工程實(shí)現(xiàn)Conntroller加載,一直報錯404,調(diào)試許久沒找到問題,請求幫助,多謝各位了!
編程環(huán)境:win10x64+eclipse+Tomcat8.5
文件結(jié)構(gòu):

主要代碼:
web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>MyWeb</display-name> <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> <!-- 加載spring配置文件 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springMvc.xml</param-value> </context-param> <!-- spring監(jiān)聽 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 配置springMvc --> <servlet> <servlet-name>springMvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springMvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> <async-supported>true</async-supported> </servlet> <servlet-mapping> <servlet-name>springMvc</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
HelloController.java
package com.hello;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HelloController {
@RequestMapping("/success")
public String helloWorld() {
System.out.println("攔截");
return "success";
}
}
springMvc.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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd "> <mvc:annotation-driven /> <context:component-scan base-package="com.hello"/> <!-- 處理靜態(tài)資源 --> <mvc:default-servlet-handler/> <!-- 配置視圖解析器 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean> </beans>
調(diào)試圖:


到此這篇關(guān)于關(guān)于springmvc報錯404的問題的文章就介紹到這了,更多相關(guān)springmvc報錯404內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
IDEA實(shí)現(xiàn)添加 前進(jìn)后退 到工具欄的操作
這篇文章主要介紹了IDEA 前進(jìn) 后退 添加到工具欄的操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-02-02
Java對象池pool2分析PooledObjectFactory過程
文章介紹了Java中對象池化技術(shù)的背景,以Apache的Pool2庫為例,詳細(xì)講解了GenericObjectPool的構(gòu)造函數(shù)參數(shù)和PooledObjectFactory接口的實(shí)現(xiàn),通過商場里的共享充電寶的比喻,說明了池化思維的應(yīng)用2025-02-02
Java并發(fā)包工具類CountDownLatch的應(yīng)用詳解
CountDownLatch是Java并發(fā)包中非常實(shí)用的一個工具類,它可以幫助我們實(shí)現(xiàn)線程之間的同步和協(xié)作。本文主要介紹了CountDownLatch的應(yīng)用場景及最佳實(shí)踐,希望對大家有所幫助2023-04-04
Kotlin?標(biāo)準(zhǔn)函數(shù)和靜態(tài)方法示例詳解
這篇文章主要為大家介紹了Kotlin?標(biāo)準(zhǔn)函數(shù)和靜態(tài)方法示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-10-10
redisson 實(shí)現(xiàn)分布式鎖的源碼解析
這篇文章主要介紹了redisson 實(shí)現(xiàn)分布式鎖的源碼解析,通過模擬一個商品秒殺的場景結(jié)合示例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-05-05
Spring Cloud Ribbon負(fù)載均衡器處理方法
這篇文章主要介紹了Spring Cloud Ribbon負(fù)載均衡器處理方法,看看是如何獲取服務(wù)實(shí)例,獲取以后做了哪些處理,處理后又是如何選取服務(wù)實(shí)例的,需要的朋友可以參考下2018-02-02
ElasticSearch不停機(jī)重建索引延伸思考及優(yōu)化詳解
這篇文章主要為大家介紹了ElasticSearch不停機(jī)重建索引延伸思考及優(yōu)化詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02
java基于jdbc連接mysql數(shù)據(jù)庫功能實(shí)例詳解
這篇文章主要介紹了java基于jdbc連接mysql數(shù)據(jù)庫功能,結(jié)合實(shí)例形式詳細(xì)分析了jdbc連接mysql數(shù)據(jù)庫的原理、步驟、實(shí)現(xiàn)方法及相關(guān)操作技巧,需要的朋友可以參考下2017-10-10
Mybatis-Plus讀寫Mysql的Json字段的操作代碼
這篇文章主要介紹了Mybatis-Plus讀寫Mysql的Json字段的操作代碼,文中通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-04-04

