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

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

java - springmvc 無法掃描到controller層

瀏覽:99日期:2024-01-29 11:15:04

問題描述

各種404,請求/user/showUser不能進入controller,整了一天,快瘋了,求組各位大神!直接上代碼項目結構:java - springmvc 無法掃描到controller層

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_3_0.xsd' xsi:schemaLocation='http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd' version='3.0'> <display-name>Archetype Created Web Application</display-name> <!-- Spring 配置文件路徑,此處可將Spring MVC的相關配置內容配置到Spring的配置文件applicationContext.xml中,共享同一個配置文件即可 --> <context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value> </context-param> <!-- Spring 監聽器 配置 --> <listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener><listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener> <!-- 字符集 過濾器 --> <filter><filter-name>CharacterEncodingFilter</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>CharacterEncodingFilter</filter-name><url-pattern>/*</url-pattern> </filter-mapping> <!-- Spring mvc 配置,配置文件名稱默認為{servlet-name}-servlet.xml,路徑默認在/WEB-INF/下 --> <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/spring-mvc.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><welcome-file-list><welcome-file>index.html</welcome-file> </welcome-file-list></web-app>

applicationContent.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-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd'> <mvc:annotation-driven /> <!-- 自動掃描 --> < <context:component-scan base-package='com.chs'><context:exclude-filter type='annotation' expression='org.springframework.stereotype.Controller' /> </context:component-scan <!-- 引入配置文件 --> <bean class='org.springframework.beans.factory.config.PropertyPlaceholderConfigurer'><property name='location' value='classpath:dataSource.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><!-- 連接池最大數量 --><property name='maxActive' value='${maxActive}'></property><!-- 連接池最大空閑 --><property name='maxIdle' value='${maxIdle}'></property><!-- 連接池最小空閑 --><property name='minIdle' value='${minIdle}'></property><!-- 獲取連接最大等待時間 --><property name='maxWait' value='${maxWait}'></property> </bean> <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --> <bean class='org.mybatis.spring.SqlSessionFactoryBean'><property name='dataSource' ref='dataSource' /><!-- 自動掃描mapping.xml文件 --><property name='mapperLocations' value='classpath:mybatisMappingConfig/*.xml'></property> </bean> <!-- DAO接口所在包名,Spring會自動查找其下的類 --> <bean class='org.mybatis.spring.mapper.MapperScannerConfigurer'><property name='basePackage' value='com.chs.dao' /><property name='sqlSessionFactoryBeanName' value='sqlSessionFactory'></property> </bean> <!-- (事務管理)transaction manager, use JtaTransactionManager for global tx --> <bean class='org.springframework.jdbc.datasource.DataSourceTransactionManager'><property name='dataSource' ref='dataSource' /> </bean></beans>

spring-mvc.xml<?xml version='1.0' encoding='UTF-8'?><beans xmlns='http://www.springframework.org/schema/beans'

xmlns:mvc='http://www.springframework.org/schema/mvc' xmlns:context='http://www.springframework.org/schema/context'xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:p='http://www.springframework.org/schema/p'xsi:schemaLocation='http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd'><!-- 添加注解驅動 --><mvc:annotation-driven /><!-- 自動掃描該包,使SpringMVC認為包下用了@controller注解的類是控制器 --><context:component-scan base-package='com.chs.controller' use-default-filters='false'> <context:include-filter type='annotation'expression='org.springframework.stereotype.Controller' /></context:component-scan><!--避免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><!-- 啟動SpringMVC的注解功能,完成請求和注解POJO的映射 --><bean class='org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter'> <property name='messageConverters'><list> <ref bean='mappingJacksonHttpMessageConverter' /> <!-- JSON轉換器 --></list> </property></bean>

<bean class='org.springframework.web.servlet.view.InternalResourceViewResolver'> <property name='order' value='10'></property> <property name='prefix' value='/WEB-INF/page/'></property> <property name='suffix' value='.html'></property> <property name='contentType' value='text/html;charset=utf-8'></property></bean><!-- ===================================================== --><!-- ViewResolver For FreeMarker --><!-- ===================================================== --><bean class='org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver'> <property name='order' value='0' /> <property name='suffix' value='.html' /> <property name='contentType' value='text/html;charset=utf-8' /> <property name='viewClass'><value>org.springframework.web.servlet.view.freemarker.FreeMarkerView</value> </property></bean><!-- ===================================================== --><!-- ViewResolver For FreeMarkerConfigurer --><!-- ===================================================== --><bean class='org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer'> <property name='templateLoaderPath'><value>/WEB-INF/page/</value> </property> <property name='freemarkerSettings'><!-- 設置FreeMarker環境屬性 --><props> <prop key='template_update_delay'>5</prop><!--刷新模板的周期,單位為秒 --> <prop key='default_encoding'>UTF-8</prop><!--模板的編碼格式 --> <prop key='locale'>UTF-8</prop><!-- 本地化設置 --> <prop key='datetime_format'>yyyy-MM-dd HH:mm:ss</prop> <prop key='time_format'>HH:mm:ss</prop> <prop key='number_format'>0.####</prop> <prop key='boolean_format'>true,false</prop> <prop key='whitespace_stripping'>true</prop> <prop key='tag_syntax'>auto_detect</prop> <prop key='url_escaping_charset'>UTF-8</prop></props> </property></bean><!-- 處理靜態資源 --><mvc:resources mapping='/css/**/' location='/css/' /><mvc:resources mapping='/imgages/**/' location='/imgges/' /><mvc:resources mapping='/js/**/' location='/js/' /><!-- 文件上傳配置 --><bean class='org.springframework.web.multipart.commons.CommonsMultipartResolver'> <!-- 默認編碼 --> <property name='defaultEncoding' value='UTF-8' /> <!-- 上傳文件大小限制為31M,31*1024*1024 --> <property name='maxUploadSize' value='32505856' /> <!-- 內存中的最大值 --> <property name='maxInMemorySize' value='4096' /></bean>

</beans>

controller

package com.chs.controller;import java.util.Map;import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping;import com.chs.base.util.ReflectionUtil;import com.chs.model.User;import com.chs.service.IUserService; @Controller @RequestMapping('/user') public class UserController { @Resource private IUserService userService;@RequestMapping('/showUser') public String toIndex(HttpServletRequest request,Model model){ System.out.println('------------------------'); Map<String, Object> paramMap = ReflectionUtil.po2Map(request); User user = this.userService.getUserById(paramMap); return 'showUser'; } }

問題解答

回答1:

會不會是jsp里的請求路徑問題,建議試下改成絕對路徑試下

標簽: java
相關文章:
主站蜘蛛池模板: 亚洲欧美日韩国产综合高清 | 杨晨晨福利视频 | 99re6这里有精品热视频在线 | 牛人国产偷窥女洗浴在线观看 | 欧美日韩在线观看一区 | 中文精品久久久久国产网址 | 久久视奸 | 亚洲一区二区影院 | 亚洲特一级毛片 | 成人一级免费视频 | 成人18免费观看的软件 | 久久精品免观看国产成人 | 亚洲精品aaa | 九九九免费视频 | 亚洲国产成人精品久久 | 毛片com | 欧美日韩成人在线视频 | 波多野结衣免费观看视频 | 国内精品伊人久久久久妇 | 成人高清在线观看播放 | 成人午夜天 | 日本韩国三级在线 | 中字毛片 | 国产成人lu在线视频 | 乱人伦中文视频在线观看免费 | 国产一级影片 | 亚洲欧美综合一区二区三区四区 | 性猛交毛片| 亚洲精品成人av在线 | 久久香蕉国产线看免费 | 欧美5g影院天天爽天天看 | 九九精品视频在线观看九九 | 成人午夜久久 | 国产成人午夜精品影院游乐网 | 中文字幕亚洲日本岛国片 | 国产精品系列在线一区 | 三级毛片网 | 真人一级毛片国产 | 日本三级在线观看中文字 | 99在线视频观看 | 美女视频黄a视频免费全程 美女视频黄a视频免费全过程 |