Spring MVC 表单控制器实现验证用户登录验证

转自:http://blog.csdn.net/happyunbound/article/details/8236106

web.xml:

[html]  view plain copy
  1. xml version="1.0" encoding="UTF-8"?>  
  2. <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   
  5.     http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">  
  6.     <servlet>  
  7.           
  8.         <servlet-name>dispatcherServletservlet-name>  
  9.           
  10.         <servlet-class>org.springframework.web.servlet.DispatcherServletservlet-class>  
  11.           
  12.         <init-param>  
  13.               
  14.             <param-name>contextConfigLocationparam-name>  
  15.               
  16.             <param-value>/WEB-INF/applicationContext.xmlparam-value>  
  17.         init-param>  
  18.           
  19.         <load-on-startup>1load-on-startup>  
  20.     servlet>  
  21.       
  22.     <servlet-mapping>  
  23.         <servlet-name>dispatcherServletservlet-name>  
  24.         <url-pattern>*.htmlurl-pattern>  
  25.     servlet-mapping>  
  26.     <welcome-file-list>  
  27.         <welcome-file>index.jspwelcome-file>  
  28.     welcome-file-list>  
  29. web-app>  


 

applicationContext.xml:

[html]  view plain copy
  1. xml version="1.0" encoding="UTF-8"?>  
  2. <beans  
  3.     xmlns="http://www.springframework.org/schema/beans"  
  4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  5.     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">  
  6.       
  7.     <bean name="/userLogin.html" class="com.jwy.controller.UserLoginController">  
  8.         <property name="commandClass">  
  9.             <value>com.jwy.controller.Uservalue>  
  10.         property>  
  11.           
  12.         <property name="formView">  
  13.             <value>index.jspvalue>  
  14.         property>  
  15.           
  16.         <property name="successView">  
  17.             <value>login.jspvalue>  
  18.         property>  
  19.     bean>  
  20. beans>  


index.jsp:

[html]  view plain copy
  1. <%@ page language="java" contentType="text/html" pageEncoding="GBK"%>  
  2. >  
  3. <html>  
  4.     <head>  
  5.         <title>文件名映射控制器title>  
  6.           
  7.         <style type="text/css">  
  8.   
  9.         <style type="text/css">  

你可能感兴趣的:(Java,Web)