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

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

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

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

問(wèn)題描述

項(xiàng)目結(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è)計(jì)路徑變量值 --> <context-param><param-name>webAppRootKey</param-name><param-value>springmvc.root</param-value> </context-param> <!-- Spring字符集過(guò)濾器 --> <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> <!-- 錯(cuò)誤跳轉(zhuǎn)頁(yè)面 --> <error-page><!-- 路徑不正確 --><error-code>404</error-code><location>/WEB-INF/view/errpage/404.jsp</location> </error-page> <error-page><!-- 沒(méi)有訪問(wèn)權(quán)限,訪問(wèn)被禁止 --><error-code>405</error-code><location>/WEB-INF/view/errpage/405.jsp</location> </error-page> <error-page><!-- 內(nèi)部錯(cuò)誤 --><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'> <!-- 自動(dòng)掃描 --> <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}'/><!-- 獲取連接最大等待時(shí)間 --><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' /><!-- 自動(dòng)掃描mapping.xml文件 --><property name='mapperLocations' value='classpath:mapper/*.xml'/> </bean> <!-- DAO接口所在包名,Spring會(huì)自動(dòng)查找其下的類 --> <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 /> <!-- 自動(dòng)掃描該包,使SpringMVC認(rèn)為包下用了@controller注解的類是控制器 --> <context:component-scan base-package='com.nazi.bbs.controller'/> <!--避免IE執(zhí)行AJAX時(shí),返回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,怎么解決?

問(wèn)題解答

回答1:

貼 spring 的 xml 文件上來(lái)看看

回答2:

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

回答3:

如果jsp頁(yè)面打不開,說(shuō)明項(xiàng)目沒(méi)有部署如果jsp打得開,controller打不開,就在controller中寫個(gè)構(gòu)造函數(shù),看項(xiàng)目啟動(dòng)的時(shí)候有沒(méi)有調(diào)用,如果沒(méi)有調(diào)用,要么是你掃包的名字寫錯(cuò)了,要么就是沒(méi)有編譯成功,部署的war包里沒(méi)這個(gè)class文件

標(biāo)簽: java
相關(guān)文章:
主站蜘蛛池模板: 中文字幕精品视频在线 | 无码精品一区二区三区免费视频 | 国产美女拍拍拍在线观看 | 美女扒开双腿让男人桶 | 久久99久久99精品观看 | 国产三级日本三级日产三 | 手机看片99 | 欧美亚洲另类视频 | 女人精aaaa片一级毛片女女 | 亚洲成人在线视频网站 | 欧美激情视频在线观看一区二区三区 | 中文字幕一级片 | 久久久亚洲欧洲日产国码二区 | 亚洲第一视频在线观看 | 免费 视频 1级 | 成年午夜一级毛片视频 | 国产婷婷一区二区三区 | 成人精品免费视频 | 一区二区精品在线 | 一级做a爰片久久毛片人呢 一级做a爰片久久毛片唾 | 萌白酱白丝护士服喷水铁牛tv | 成人a毛片在线看免费全部播放 | 欧美精品在线一区二区三区 | 欧洲成人在线 | 国产精品久久久久久福利漫画 | 国产色手机在线观看播放 | 中文字幕乱码中文乱码综合 | 亚洲伊人色| 久草视频资源站 | 国产精品视频久久 | 99视频在线观看视频 | 一及毛片 | 伊人久久在线 | 另类视频一区 | 国产一级在线 | 欧美亚洲国产精品久久久 | 欧美性生交大片免费看 | 亚洲欧美卡通成人制服动漫 | 国产婷婷成人久久av免费高清 | 99热久久免费精品首页 | 99精品视频在线观看免费 |