国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術(shù)文章
文章詳情頁

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

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

問題描述

項目結(jié)構(gòu):

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> <!-- 起始?xì)g迎界面 --> <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> <!-- 設(shè)計路徑變量值 --> <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> <!-- 攔截設(shè)置 --> <servlet-mapping><servlet-name>dispatcherServlet</servlet-name><url-pattern>/</url-pattern> </servlet-mapping> <!-- 錯誤跳轉(zhuǎn)頁面 --> <error-page><!-- 路徑不正確 --><error-code>404</error-code><location>/WEB-INF/view/errpage/404.jsp</location> </error-page> <error-page><!-- 沒有訪問權(quán)限,訪問被禁止 --><error-code>405</error-code><location>/WEB-INF/view/errpage/405.jsp</location> </error-page> <error-page><!-- 內(nèi)部錯誤 --><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}'/><!-- 連接池最大數(shù)量 --><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認(rèn)為包下用了@controller注解的類是控制器 --> <context:component-scan base-package='com.nazi.bbs.controller'/> <!--避免IE執(zhí)行AJAX時,返回JSON出現(xiàn)下載文件 --> <bean class='org.springframework.http.converter.json.MappingJacksonHttpMessageConverter'><property name='supportedMediaTypes'> <list><value>text/html;charset=UTF-8</value> </list></property> </bean> <!-- 定義跳轉(zhuǎn)的文件的前后綴 ,視圖模式配置--> <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中寫個構(gòu)造函數(shù),看項目啟動的時候有沒有調(diào)用,如果沒有調(diào)用,要么是你掃包的名字寫錯了,要么就是沒有編譯成功,部署的war包里沒這個class文件

標(biāo)簽: java
相關(guān)文章:
主站蜘蛛池模板: 国产另类视频 | 高清 国产 日韩 欧美 | 久久久久久88色愉愉 | 真人一级一级特黄高清毛片 | 性色综合 | www成人国产在线观看网站 | 成人精品国产亚洲欧洲 | 久久99精品这里精品3 | 2021国内自拍 | 黄色日韩网站 | 亚洲国产欧美日韩精品一区二区三区 | 中美日韩在线网免费毛片视频 | 亚洲欧美人妖另类激情综合区 | 亚洲精品国产成人专区 | 欧美日韩中文国产一区二区三区 | 亚洲国产第一区二区香蕉 | 白白在线观看永久免费视频 | 狠狠色综合久久丁香婷婷 | 亚洲精品一区二区三区在线播放 | 欧美日韩视频在线 | 91精品手机国产露脸 | 欧美日韩免费一区二区在线观看 | 免费在线观看a级片 | 国产a∨一区二区三区香蕉小说 | 91老色批网站免费看 | 日本国产一区二区三区 | 亚洲精品免费网站 | 亚洲一区二区免费视频 | 国产一区二区影视 | 成人毛片免费 | 成人午夜大片 | 色琪琪一本到影院 | 韩日黄色 | 欧美成年黄网站色视频 | 四虎免费大片aⅴ入口 | 国内精品亚洲 | 国产性tv国产精品 | 青青爽国产手机在线观看免费 | 国产在线一区二区三区欧美 | 欧美成人se01短视频在线看 | 手机看片神马午夜片 |