问答详情
源自:3-1 工程建立及工程结构

求源代码?

中间省略了很多配置的文件和jsp页面,求代码


提问者:Chen锁 2016-12-06 11:37

个回答

  • 996木马
    2016-12-16 00:22:28
    已采纳

    <?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>


  • HelloiM00c
    2016-12-14 14:55:38

    可参照这个源代码https://github.com/GongchuangSu/HelloWeb