当前位置:首页 > 资讯 > info6 > 正文

spring+mybatis

发表于: 2015-02-12   作者:chelsi916   来源:转载   浏览:
摘要: DisableUrlSessionFilter.java packagecom.sf.hkbw.context.filter; importjava.io.IOException; importjavax.servlet.Filter; importjavax.servlet.FilterChain; importjavax.servlet.FilterConfig; importjavax
DisableUrlSessionFilter.java
package com.sf.hkbw.context.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import javax.servlet.http.HttpSession;

public class DisableUrlSessionFilter implements Filter {
	
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		if (!(request instanceof HttpServletRequest)) {
			chain.doFilter(request, response);
			return;
		}

		HttpServletRequest httpRequest = (HttpServletRequest) request;
		HttpServletResponse httpResponse = (HttpServletResponse) response;

		if (httpRequest.isRequestedSessionIdFromURL()) {
			HttpSession session = httpRequest.getSession();
			if (session != null) {
				session.invalidate();
			}
		}
		
		// wrap response to remove URL encoding
		HttpServletResponseWrapper wrappedResponse = new HttpServletResponseWrapper(httpResponse) {
			
			@Override
			public String encodeRedirectUrl(String url) {
				return url;
			}

			public String encodeRedirectURL(String url) {
				return url;
			}

			public String encodeUrl(String url) {
				return url;
			}

			public String encodeURL(String url) {
				return url;
			}
		};
		chain.doFilter(request, wrappedResponse);
	}

	public void init(FilterConfig config) throws ServletException {
		
	}

	public void destroy() {
		
	}
}

LoginInterceptor.java

package com.sf.hkbw.context.interceptor;

import java.net.URLEncoder;
import java.util.List;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import com.sf.hkbw.entity.Address;
import com.sf.hkbw.entity.ResultVO;
import com.sf.hkbw.utils.Constants;
import com.sf.hkbw.utils.CookieUtil;
import com.sf.hkbw.utils.LbsUtil;
import com.sf.hkbw.utils.StringUtils;


/**
 * 拦截器
 * @author 674045
 *
 */
public class LoginInterceptor implements HandlerInterceptor {


    /**
     * 不需要登录的url(完整)
     */
    private List<String> excludeUris;
    /**
     * 不需要登录的url(开头)
     */
    private List<String> excludeStartsUris;
    
    public List<String> getExcludeUris() {
		return excludeUris;
	}

	public void setExcludeUris(List<String> excludeUris) {
		this.excludeUris = excludeUris;
	}

	public List<String> getExcludeStartsUris() {
		return excludeStartsUris;
	}

	public void setExcludeStartsUris(List<String> excludeStartsUris) {
		this.excludeStartsUris = excludeStartsUris;
	}

	public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3) throws Exception {
    }

    public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3) throws Exception {
    }

    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object arg2) throws Exception {
//        request.setCharacterEncoding("UTF-8");
//        response.setCharacterEncoding("UTF-8");
//        response.setContentType("text/html;charset=UTF-8");
//        String url = request.getRequestURI();
//        if (excludeUris.contains(url)) {
//            return true;
//        }
//        for (String startsUrl : excludeStartsUris) {
//            if (url.startsWith(startsUrl)) {
//                return true;
//            }
//        }
//        if(request.getCookies()!=null){
//        	 return true;
//        }
//        
//        String postIp =LbsUtil.getIpAddr(request);
//        /**
//         * 通过IP判断用户地址
//         */
//        ResultVO addressOfIp = LbsUtil.getAddress("ip=220.198.192.12", "utf-8");	
//        if(addressOfIp !=null){
//	        Address address = addressOfIp.getData();
//	        if(StringUtils.isBlank(address.getCity())){
//	        	redirectUrl(request,response,url);
//	    		return false;
//	        }else{	        	 
//	    		CookieUtil.setCookie(request, response,Constants.CITY ,URLEncoder.encode(address.getCity(), "utf-8"));
//	    		CookieUtil.setCookie(request, response,Constants.CITY_ID ,address.getCity_id());  
//	        	return true;
//	        }  
//        }else{
//        	redirectUrl(request,response,url);
//    		return false;
//        }
    	return true;
        
    }

//    private void redirectUrl(HttpServletRequest request,HttpServletResponse response, String url ) throws Exception{
//    	String param = request.getQueryString();
//		if (param == null) {
//			param = "";
//        } else {
//        	param = "?" + param;
//        }
//		String redirect_url = StringUtils.getEncoder(url + param);
//		response.sendRedirect("/ip/resetCity?url=" + redirect_url);
//    }
  
}

BaseController.java

package com.sf.hkbw.controller;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONObject;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;

import com.sf.hkbw.config.LogAppender;
import com.sf.hkbw.entity.AdminFunctions;
import com.sf.hkbw.entity.AdminUsers;
import com.sf.hkbw.entity.ErrorLog;
import com.sf.hkbw.entity.vo.ResultDTO;
import com.sf.hkbw.service.AdminFunctionsService;
import com.sf.hkbw.service.ErrorLogService;
import com.sf.hkbw.utils.CommonHelper;
import com.sf.hkbw.utils.PrimaryKeyGen;


/**
 * 
 * @author sfit0709
 *
 */
@Controller
public class BaseController {
	//日志对象
	protected final transient Logger log = Logger.getLogger(LogAppender.DEFAULT);
	protected HttpServletRequest request;
	protected HttpServletResponse response;
	protected HttpSession session;
	
	//菜单
	@Autowired private AdminFunctionsService adminFunctionsService;	
    //异常处理
	@Autowired private ErrorLogService errorLogService;
	
	@ModelAttribute
	public void setRequestAndResponse(HttpServletRequest request, HttpServletResponse response) {
		this.request = request;
		this.response = response;
		this.session = request.getSession(true);
	}
	
	public void writeJSON(String status, String message) {
		try {
			response.setContentType("text/html; charset=utf-8");
			if (null == status) status = "";
			if (null == message) message = "";
			Map<String, String> map = new HashMap<String, String>();
			map.put("status", status);
			map.put("message", message);
			response.getWriter().print(JSONObject.fromObject(map));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void writeJSON(String status) {
		try {
			response.setContentType("text/html; charset=utf-8");
			if (null == status) status = "";
			Map<String, String> map = new HashMap<String, String>();
			map.put("status", status);
			response.getWriter().print(JSONObject.fromObject(map));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	public void writeJSON(String status, String message, HttpServletResponse response) {
		try {
			response.setContentType("text/html; charset=utf-8");
			
			if (null == status) status = "";
			if (null == message) message = "";
			
			Map<String, String> map = new HashMap<String, String>();
			map.put("status", status);
			map.put("message", message);
			
			response.getWriter().print(JSONObject.fromObject(map));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void writeJSON(Object status, Object message, HttpServletResponse response) {
		try {
			response.setContentType("text/html; charset=utf-8");
			
			if (null == status) status = "";
			if (null == message) message = "";
			
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("status", status);
			map.put("message", message);
			
			response.getWriter().print(JSONObject.fromObject(map));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 输出到页�?
	 * @param str 输出参数
	 * @param charset 编码格式
	 */
	protected void writeAjaxResult(String str, String charset, HttpServletResponse response) {
		try {
			response.getOutputStream().write(str.getBytes(charset));
		} catch (Exception e) {
			log.error("ajax output exception", e);
		}
	}

	/**
	 * 输出到页�?默认编码格式UTF-8
	 * @param str 输出参数
	 */
	protected void writeAjaxResult(String str, HttpServletResponse response) {
		try {
			this.writeAjaxResult(str, "UTF-8", response);
		} catch (Exception e) {
			log.error("ajax output exception", e);
		}
	}
	
	public void responseResult(Object result, HttpServletResponse response){
		try {
			response.setContentType("text/html;charset=utf-8");
			response.getWriter().print(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void responseJson(Object obj, HttpServletResponse response){
		try {
			response.setContentType("application/json;charset=utf-8");
			response.getWriter().print(JSONObject.fromObject(obj));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public <T> void resultString (int status, String msg, Object data, HttpServletResponse response) {
		ResultDTO<T> result = setResultDTO(status, msg);
		result.setData(data);
		responseJson(result, response);
	}
	
	public <T> void resultList (int status, String msg, List<T> list, HttpServletResponse response) {
		ResultDTO<T> result = setResultDTO(status, msg);
		result.setList(list);
		responseJson(result, response);
	}
	
	public <T> void resultMap (int status, String msg, Map<String, Object> map, HttpServletResponse response) {
		ResultDTO<T> result = setResultDTO(status, msg);
		result.setMap(map);
		responseJson(result, response);
	}
	
	private <T> ResultDTO<T> setResultDTO(int status, String msg) {
		ResultDTO<T> result = new ResultDTO<T>();
		result.setStatus(status);
		result.setMsg(msg);
		return result;
	}
	
	public List<AdminFunctions> getBtns(AdminUsers adminUser,String url){
		System.out.println(url);
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("userId", adminUser.getId());
		params.put("jspUrl", url);
		return adminFunctionsService.getJspButtonList(params);	
	}
	
	/**
	 * TODO  记录抛出异常信息
	 * @author WangFei 681487
	 * @date   2015-2-6下午5:35:20
	 */
	
	
	/**
	 * TODO  记录异常信息
	 * @param adminUser
	 * @param className
	 * @param methodName
	 * @param serverIp
	 * @param ex
	 * @author WangFei 681487
	 * @date   2015-2-6下午5:45:13
	 */
	public void addErrorLog(AdminUsers adminUser,String className,String methodName,Exception ex){
		ErrorLog errorLog= new ErrorLog();
		errorLog.setId(PrimaryKeyGen.genPrimaryKey());
		errorLog.setClassName(className);
		errorLog.setMethodName(methodName);
		errorLog.setServerIp(CommonHelper.getServerId());
		errorLog.setStatus("0");
		errorLog.setLogText(ex.toString());
		errorLog.setCreateBy(adminUser.getUserName());
		errorLogService.addErrorLog(errorLog);
	}
}

applicationContext.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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="
	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
	http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
	http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

	<!-- 启动Spring MVC的注解功能,完成请求和注解POJO -->
	<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
		<property name="messageConverters">
			<list>
				<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
			</list>
		</property>
	</bean>
	
	<mvc:view-controller path="/" view-name="index"/>

	<!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 -->
	<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
		<property name="prefix" value="/WEB-INF/views/" />
		<property name="suffix" value=".jsp" />
	</bean>
	
	<!-- 解决 @PathVariable 截取小数点的问题 -->
	<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">  
        <property name="useDefaultSuffixPattern" value="false" />  
    </bean> 

	<!-- 拦截所有请求 -->
	<mvc:interceptors>
		<mvc:interceptor>
			<mvc:mapping path="/**" />
			<bean class="com.sf.hkbw.context.interceptor.LoginInterceptor">
				<property name="excludeUris">
					<list>
					     <value>/login</value>
					</list>
				</property>
				<property name="excludeStartsUris">
					<list>
					    <value>/api/index</value>
					</list>
				</property>
			</bean>
		</mvc:interceptor>
	</mvc:interceptors>

	<!-- 支持上传文件 -->
	<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" p:defaultEncoding="utf-8">
		<property name="maxUploadSize">
			<value>10000000</value>
		</property>
		<property name="maxInMemorySize">
			<value>4096</value>
		</property>
	</bean>

	<bean class="com.sf.hkbw.utils.SpringContextUtils"></bean>
</beans>


jdbc.properties

#jdbc2 mysql wf127.0.0.1
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://127.0.0.1:3306/oma
#jdbc.username=root
#jdbc.password=123456

#jdbc2 mysql 10.118.46.20
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://10.118.46.20:3306/OMA?useUnicode=true&characterEncoding=utf8
jdbc.username=mysql
jdbc.password=

jdbc.maxActive=100
jdbc.maxIdle=30
jdbc.maxWait=10000


log4j.properties:

log4j.logger.com.springframework=DEBUG
log4j.logger.com.ibatis=DEBUG  
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG  
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG  
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG  
log4j.logger.java.sql.Connection=DEBUG  
log4j.logger.java.sql.Statement=DEBUG  
log4j.logger.java.sql.PreparedStatement=DEBUG  
log4j.logger.java.sql.ResultSet=DEBUG

log4j.rootLogger = INFO,default
log4j.additivity.org.apache=false

log4j.logger.register = INFO, register
log4j.logger.login = INFO, login
log4j.logger.role = INFO, role
log4j.logger.menu = INFO, menu
log4j.logger.api = INFO, api
log4j.logger.orders = INFO, orders
log4j.logger.adminuser = INFO, adminuser
log4j.logger.apiLog = INFO, apiLog
log4j.logger.propertyValueSet = INFO, propertyValueSet
log4j.logger.accountDetail = INFO, accountDetail

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

### register ###
log4j.appender.register = org.apache.log4j.DailyRollingFileAppender
log4j.appender.register.file = /app/applogs/HBMS-OMA/register/register.log
log4j.appender.register.DatePattern='.'yyyy-MM-dd
log4j.appender.register.layout=org.apache.log4j.PatternLayout
log4j.appender.register.layout.ConversionPattern=[%-5p] [%c] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [%t] [%l] - [%m]%n\

### login ###
log4j.appender.login = org.apache.log4j.DailyRollingFileAppender
log4j.appender.login.file = /app/applogs/HBMS-OMA/login/login.log
log4j.appender.login.DatePattern='.'yyyy-MM-dd
log4j.appender.login.layout=org.apache.log4j.PatternLayout
log4j.appender.login.layout.ConversionPattern=[%-5p] [%c] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [%t] [%l] - [%m]%n\

WebContent/WEB-INF/spring-servlet.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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="
	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
	http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
	http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
    
    <!-- 使用spring注解 -->
	<context:annotation-config />
	<context:component-scan base-package="com.sf.hkbw.controller" />
	<context:component-scan base-package="com.sf.hkbw.service" />
	
	<!-- LDAP domain user verify -->
	<bean id="contextSoureTarget" class="org.springframework.ldap.core.support.LdapContextSource">
		<property name="url" value="ldap://HQDC02.SF.COM/"></property>
		<property name="base" value="OU=SF-Express,DC=sf,DC=com"></property>
		<property name="referral" value="follow"></property>
		<!-- 域账号和密码设置(域账号格式为sf\******) 
		<property name="userDn" value="sf\member"/> 
		<property name="password" value="1qazxcvbnm,"/> -->
	</bean>

	<bean id="ldapAuthenticationBiz" class="com.sf.hkbw.service.LdapAuthenticationService">
		<property name="contextSource" ref="contextSoureTarget" />
		<property name="prefix" value="sf\" />
	</bean>
		
	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations" value="classpath:/*.properties" />
	</bean>

 	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName" value="${jdbc.driver}" />
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
	</bean>

	<!-- 定义事物管理器 -->
	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>

	<tx:annotation-driven proxy-target-class="true" transaction-manager="transactionManager" />

	<!-- 事物传播属性 -->
	<tx:advice id="txadvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="insert*" propagation="REQUIRED" />
			<tx:method name="create*" propagation="REQUIRED" />
			<tx:method name="save*" propagation="REQUIRED" />
			<tx:method name="add*" propagation="REQUIRED" />
			<tx:method name="update*" propagation="REQUIRED" />
			<tx:method name="modify*" propagation="REQUIRED" />
			<tx:method name="delete*" propagation="REQUIRED" />
			<tx:method name="remove*" propagation="REQUIRED" />
			<tx:method name="change*" propagation="REQUIRED" />
			<tx:method name="disposeOrderType" propagation="REQUIRED" />
		</tx:attributes>
	</tx:advice>

	<!-- 切入点 -->
	<aop:config>
		<aop:pointcut id="transactionPointcut" expression="execution(* com.sf.hkbw..*.service..*.*(..))" />
		<aop:advisor advice-ref="txadvice" pointcut-ref="transactionPointcut" />
	</aop:config>

	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
	</bean>

	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.sf.hkbw.mapper" />
	</bean>
	
	<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
	    <property name="corePoolSize" value="10"/>
	    <property name="maxPoolSize" value="50"/>
	</bean>
</beans>

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">
  <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>
  <filter>
    <filter-name>jsessionid</filter-name>
    <filter-class>com.sf.hkbw.context.filter.DisableUrlSessionFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>jsessionid</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml,WEB-INF/spring-servlet.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
  </listener>
  <servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.jpg</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.swf</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.JPG</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.png</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.gif</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.jpeg</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.js</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.css</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.xml</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.html</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.htm</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.exe</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.ico</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.properties</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.txt</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.pdf</url-pattern>
  </servlet-mapping>
  <error-page>
    <error-code>404</error-code>
    <location>/error/404.html</location>
  </error-page>
  <error-page>
    <error-code>500</error-code>
    <location>/error/500.html</location>
  </error-page>
  <welcome-file-list>
    <welcome-file>/index.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>VerifyCodeServlet</servlet-name>
    <servlet-class>com.sf.hkbw.utils.VerifyCodeServlet</servlet-class>
    <init-param>
      <param-name>num</param-name>
      <param-value>4</param-value>
    </init-param>
    <init-param>
      <param-name>content</param-name>
      <param-value>abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ23456789</param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
    <servlet-name>VerifyCodeServlet</servlet-name>
    <url-pattern>/security/random</url-pattern>
  </servlet-mapping>
  <resource-ref>
    <res-ref-name>omaDS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>
  
<!-- 	<session-config>
	    <session-timeout>1</session-timeout>
	</session-config> -->  
	
</web-app>


spring+mybatis

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号