为了账号安全,请及时绑定邮箱和手机立即绑定

正在回答

2 回答

<?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:aop="http://www.springframework.org/schema/aop"
	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.2.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
		http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">

	<!-- 配置自动扫描的包 -->
	<context:component-scan base-package="com.imooc">
		<context:include-filter type="annotation"
			expression="org.springframework.stereotype.Controller" />
		<context:exclude-filter type="annotation"
			expression="org.springframework.stereotype.Service" />
		<context:exclude-filter type="annotation"
			expression="org.springframework.stereotype.Repository" />
	</context:component-scan>

	<mvc:resources location="/images/" mapping="/images/**" />
	<mvc:resources location="/js/" mapping="/js/**" />
	<mvc:resources location="/style/" mapping="/style/**" />
	<mvc:resources location="/img/" mapping="/img/**" />

	<bean
		class="org.springframework.web.servlet.mvc.methdo.annotation.RequestMappingHandlerMapping"></bean>

	<bean
		class="org.springframework.web.servlet.mvc.methdo.annotation.RequestMappingHandlerAdapter">
		<property name="cacheSeconds" value="0" />
		<property name="messageConverters">
			<list>
				<ref bean="mappingJacksonHttpMessageConverter" />
				<ref bean="mappingStringHttpMessageConverter" />
			</list>
		</property>
		<property name="webBindInitializer" ref="webBindInitializer"></property>
	</bean>

	<bean id="mappingStringHttpMessageConverter"
		class="org.springframework.http.converter.StringHttpMessageConverter">
		<property name="supportedMediaTypes">
			<list>
				<value>text/plain;charset=UTF-8</value>
				<value>application/json;charset=UTF-8</value>
			</list>
		</property>
	</bean>


	<bean id="mappingJacksonHttpMessageConverter"
		class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
		<property name="supportedMediaTypes">
			<list>
				<bean class="org.springframework.http.MediaType">
					<constructor-arg index="0" value="application"></constructor-arg>
					<constructor-arg index="1" value="json"></constructor-arg>
					<constructor-arg index="2" value="UTF-8"></constructor-arg>
				</bean>
			</list>
		</property>
	</bean>

	<bean id="" webBindInitializer "
		class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
		<property name="conversionService">
			<bean
				class="org.springframework.core.convert.support.DefaultConversionService />
		</property>
	</bean>

	<!-- 配置视图解析器 如何把 handler 方法返回值解析为实际的物理视图 -->
	<bean  id="
				ViewResolver "
				class="org.springframework.web.servlet.view.InternalResourceViewResolver ">
				<property name="ignoreAcceptHeader" value="true"></property>
				<property name="mediaTypes">
					<map>
						<entry key="json" value="application/json"></entry>
						<entry key="xml" value="application/xml"></entry>
					</map>
				</property>
				<property name="defaultContentType" value="text/html"></property>
				<property name="favorParameter" value="false"></property>
				<property name="ViewResolvers">
					<list>
						<bean
							class="org.springframework.web.servlet.view.InternalResourceViewResolver">
							<property name="order" value="2" />
							<property name="prefix" value="/WEB-INF/views/" />
							<property name="suffix" value=".jsp" />
						</bean>
					</list>
				</property>
			</bean>

</beans>


0 回复 有任何疑惑可以回复我~
#1

Chen锁 提问者

非常感谢!
2016-12-26 回复 有任何疑惑可以回复我~
1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
使用SpringMVC+Spring+Hibernate开发人员信息管理功能
  • 参与学习       64962    人
  • 解答问题       86    个

Java常用框架整合案例,通过本案例的学习还可以体会项目的实现流程

进入课程

求源代码?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信