taotao-manager-web 表现层有关的: springmvc.xml、web.xml

springmvc.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:dubbo="http://code.alibabatech.com/schema/dubbo"
	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/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
        http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">

	<context:component-scan
		base-package="com.taotao.controller" />
	<mvc:annotation-driven />
	<bean
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/jsp/" />
		<property name="suffix" value=".jsp" />
	</bean>
	<!-- 配置静态资源映射 -->
	<!-- 指定/WEB-INF/js /WEB-INF/css/ 下的所有的静态资源包括子目录下的静态资源 都不被拦截 -->
	<!-- mapping=/js/** :表示访问静态资源的路径的形式 可以访问 /js/下的静态资源或者所有的子目录下的静态资源 -->
	<mvc:resources location="/WEB-INF/js/" mapping="/js/**" />
	<mvc:resources location="/WEB-INF/css/" mapping="/css/**" />

	<!-- 引用dubbo服务 -->
	<dubbo:application name="taotao-manager-web" />
	<dubbo:registry protocol="zookeeper"
		address="192.168.25.128:2181" />
	<dubbo:reference
		interface="com.taotao.service.TestService" id="testService" />
	<dubbo:reference
		interface="com.taotao.service.ItemService" id="itemService" />
</beans>

  

然后在src/main/java/spring/下,新建包com.taotao.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"
	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>taotao-manager-web</display-name>
	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
		<welcome-file>index.htm</welcome-file>
		<welcome-file>index.jsp</welcome-file>
		<welcome-file>default.html</welcome-file>
		<welcome-file>default.htm</welcome-file>
		<welcome-file>default.jsp</welcome-file>
	</welcome-file-list>
	
	<!-- 配置dispatcherservlet -->
	<!-- url的拦截形式 -->
	<!-- 加载springmvc.xml -->
	<!-- 解决post乱码 -->
	<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>
	</filter>
	<filter-mapping>
		<filter-name>CharacterEncodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<!-- springmvc的前端控制器 -->
	<servlet>
		<servlet-name>taotao-manager-web</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<!-- contextConfigLocation不是必须的, 如果不配置contextConfigLocation, springmvc的配置文件默认在:WEB-INF/servlet的name+"-servlet.xml" -->
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:spring/springmvc.xml</param-value>
		</init-param>
		<!-- load-on-startup配置为1,表示tomcat容器初始化的时候就加载。如果load-on-startup不配置,则表示我们第一次请求的时候才加载 -->
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>taotao-manager-web</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>
</web-app>

  

log4j.properties

log4j.rootLogger=WARN,A1

log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%c]-[%p] %m%n

  

原文地址:https://www.cnblogs.com/yuyu666/p/12641402.html