亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術文章
文章詳情頁

java - SpringMVC 一直提示404,怎么解決?

瀏覽:80日期:2024-01-18 16:16:12

問題描述

項目結構:

java - SpringMVC 一直提示404,怎么解決?

web.xml:

<?xml version='1.0' encoding='UTF-8'?><web-app xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://java.sun.com/xml/ns/javaee' xmlns:web='http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd' xsi:schemaLocation='http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd' version='2.5'> <display-name>SalamanderBBS</display-name> <!-- 起始歡迎界面 --> <welcome-file-list><welcome-file /> </welcome-file-list> <!-- 讀取spring配置文件 --> <context-param><param-name>contextConfigLocation</param-name><param-value>classpath:spring-mybatis.xml</param-value> </context-param> <!-- 設計路徑變量值 --> <context-param><param-name>webAppRootKey</param-name><param-value>springmvc.root</param-value> </context-param> <!-- Spring字符集過濾器 --> <filter><filter-name>SpringEncodingFilter</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value></init-param><init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value></init-param> </filter> <filter-mapping><filter-name>SpringEncodingFilter</filter-name><url-pattern>/*</url-pattern> </filter-mapping> <listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- springMVC核心配置 --> <servlet><servlet-name>dispatcherServlet</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param> <param-name>contextConfigLocation</param-name> <!--spingMVC的配置路徑 --> <param-value>classpath:spring-mvc.xml</param-value></init-param><load-on-startup>1</load-on-startup> </servlet> <!-- 攔截設置 --> <servlet-mapping><servlet-name>dispatcherServlet</servlet-name><url-pattern>/</url-pattern> </servlet-mapping> <!-- 錯誤跳轉頁面 --> <error-page><!-- 路徑不正確 --><error-code>404</error-code><location>/WEB-INF/view/errpage/404.jsp</location> </error-page> <error-page><!-- 沒有訪問權限,訪問被禁止 --><error-code>405</error-code><location>/WEB-INF/view/errpage/405.jsp</location> </error-page> <error-page><!-- 內部錯誤 --><error-code>500</error-code><location>/WEB-INF/view/errpage/500.jsp</location> </error-page></web-app>

spring-batis.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:p='http://www.springframework.org/schema/p' xmlns:context='http://www.springframework.org/schema/context' xmlns:mvc='http://www.springframework.org/schema/mvc' xmlns:tx='http://www.springframework.org/schema/tx' xmlns:aop='http://www.springframework.org/schema/aop' xsi:schemaLocation='http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-4.0.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-4.0.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-4.0.xsd'> <!-- 自動掃描 --> <context:component-scan base-package='com.nazi.bbs' /> <!-- 引入配置文件 --> <bean class='org.springframework.beans.factory.config.PropertyPlaceholderConfigurer'><property name='location' value='classpath:jdbc.properties' /> </bean> <bean destroy-method='close'><property name='driverClassName' value='${driver}' /><property name='url' value='${url}' /><property name='username' value='${username}' /><property name='password' value='${password}' /><!-- 初始化連接大小 --><property name='initialSize' value='${initialSize}'/><!-- 連接池最大數量 --><property name='maxActive' value='${maxActive}'/><!-- 連接池最大空閑 --><property name='maxIdle' value='${maxIdle}'/><!-- 連接池最小空閑 --><property name='minIdle' value='${minIdle}'/><!-- 獲取連接最大等待時間 --><property name='maxWait' value='${maxWait}'/> </bean> <bean class='org.springframework.jdbc.datasource.DataSourceTransactionManager'><property name='dataSource' ref='dataSource' /> </bean> <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --> <bean class='org.mybatis.spring.SqlSessionFactoryBean'><property name='dataSource' ref='dataSource' /><!-- 自動掃描mapping.xml文件 --><property name='mapperLocations' value='classpath:mapper/*.xml'/> </bean> <!-- DAO接口所在包名,Spring會自動查找其下的類 --> <bean class='org.mybatis.spring.mapper.MapperScannerConfigurer'><property name='basePackage' value='com.ymf.whoisquery.dao' /><property name='sqlSessionFactoryBeanName' value='sqlSessionFactory'/> </bean></beans>

spring-mvc.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:p='http://www.springframework.org/schema/p' 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-4.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-4.0.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-4.0.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-4.0.xsd'> <mvc:annotation-driven /> <!-- 自動掃描該包,使SpringMVC認為包下用了@controller注解的類是控制器 --> <context:component-scan base-package='com.nazi.bbs.controller'/> <!--避免IE執行AJAX時,返回JSON出現下載文件 --> <bean class='org.springframework.http.converter.json.MappingJacksonHttpMessageConverter'><property name='supportedMediaTypes'> <list><value>text/html;charset=UTF-8</value> </list></property> </bean> <!-- 定義跳轉的文件的前后綴 ,視圖模式配置--> <bean class='org.springframework.web.servlet.view.InternalResourceViewResolver'><property name='prefix' value='/WEB-INF/view/'/><property name='suffix' value='.jsp'/> </bean></beans>

java - SpringMVC 一直提示404,怎么解決?

問題解答

回答1:

貼 spring 的 xml 文件上來看看

回答2:

index都404?那要看一下部署的容器下面的war包是否存在,以及里面的文件是否存在。

回答3:

如果jsp頁面打不開,說明項目沒有部署如果jsp打得開,controller打不開,就在controller中寫個構造函數,看項目啟動的時候有沒有調用,如果沒有調用,要么是你掃包的名字寫錯了,要么就是沒有編譯成功,部署的war包里沒這個class文件

標簽: java
相關文章:
主站蜘蛛池模板: 亚欧洲精品在线视频免费观看 | 人人狠狠综合88综合久久 | 欧美一级欧美三级 | 特级做人爱c欧美网站 | 毛片黄片一级片 | 中文字幕日产乱码偷在线 | 日本精品一区二区三本中文 | 国产精品亚欧美一区二区三区 | 2020狠狠操 | 国产萝控精品福利视频免费 | 猫咪视频成人永久免费观看 | 日韩黄色毛片 | 亚洲综合色色图 | 看成年全黄大色黄大片 | www久草| 在线精品亚洲 | 免费一级性片 | 善良的后裔完整视频在线观看 | 鲁大师视频在线观看免费播放 | 国产精品久久久久久久久久久久久久 | 久久国产精品久久国产精品 | 中国特级黄一级真人毛片 | 国产一在线| 亚洲欧美日韩在线线精品 | 免费视频久久 | 香蕉超级碰碰碰97视频在线观看 | 亚洲第五色综合网啪啪 | 手机看片自拍自拍自拍 | 国产精品亚洲第五区在线 | 麻豆精品视频网站在线观看 | 高清不卡毛片 | 日本一级毛片在线播放 | 色视频线观看在线播放 | 91精品国产高清91久久久久久 | 色婷婷六月丁香七月婷婷 | 午夜激情在线观看 | 九九黄色大片 | 特黄日韩免费一区二区三区 | 久久久精品视频在线观看 | 亚洲高清不卡视频 | 国产精品色哟哟 |