1.

 <?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"> <!--if you not definite webAppRootKey, the default one is "webapp.root".
However, we'd better defintie in, so it will nto conflict with others.
Web container start, it will write this to system. -->
<display-name>HotelMaster</display-name> <context-param>
<param-name>webAppRootKey</param-name>
<param-value>hotelmaster.root</param-value>
</context-param> <!--Spring ApplicationContext file path, separeted by comma.
this parameter usring by Spring-Context loader--> <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/hotel-security.xml,
/WEB-INF/hotel-hibernate.xml,
/WEB-INF/hotel-servlet.xml,
/WEB-INF/hotel-services.xml
</param-value>
</context-param> <!-- Log4j -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
</context-param> <context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>60000</param-value>
</context-param> <!-- Acegi Ajax过滤器 -->
<filter>
<filter-name>acegiAjaxFilter</filter-name>
<filter-class>com.hotelmaster.home.web.filter.AcegiAjaxFilter</filter-class>
</filter> <filter>
<filter-name>logoutAjaxFilter</filter-name>
<filter-class>com.hotelmaster.home.web.filter.LogoutAjaxFilter</filter-class>
</filter>
<!-- Acegi过滤器 -->
<filter>
<filter-name>acegiFilterChain</filter-name>
<filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class>
<init-param>
<param-name>targetClass</param-name>
<param-value>org.acegisecurity.util.FilterChainProxy</param-value>
</init-param>
</filter>
<!-- Acegi Ajax 过滤器URL映射 -->
<filter-mapping>
<filter-name>acegiAjaxFilter</filter-name>
<url-pattern>/j_acegi_security_check</url-pattern>
</filter-mapping> <filter-mapping>
<filter-name>logoutAjaxFilter</filter-name>
<url-pattern>/userLogout.htm</url-pattern>
</filter-mapping> <!-- Acegi过滤器URL映射 -->
<filter-mapping>
<filter-name>acegiFilterChain</filter-name>
<url-pattern>/j_acegi_security_check</url-pattern>
</filter-mapping>
<!-- Acegi过滤器URL映射 -->
<filter-mapping>
<filter-name>acegiFilterChain</filter-name>
<url-pattern>*.htm</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping> <filter-mapping>
<filter-name>acegiFilterChain</filter-name>
<url-pattern>*.jsp</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping> <!-- Listeners -->
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener> <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <!-- DWR Config-->
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<display-name>DWR Servlet</display-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
</servlet> <servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping> <!-- Spring DispatcherServlet Config-->
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/hotel-servlet.xml</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet> <servlet-mapping>
<servlet-name>dispatcherServlet</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping> <session-config>
<session-timeout>120</session-timeout>
</session-config> <welcome-file-list>
<welcome-file>/WEB-INF/pages/index.jsp</welcome-file>
</welcome-file-list>
</web-app>

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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <!--
- This bean is an explicit URL mapper that is used by the "home" DispatcherServlet
- It is used instead of the default BeanNameUrlHandlerMapping.
-->
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="interceptors" ref="openSessionInViewInterceptor"/>
<property name="mappings">
<props>
<prop key="userLogin.htm">userLoginController</prop>
<prop key="/home.htm">homeController</prop>
<prop key="/frontdesk.htm">frontdeskController</prop>
<prop key="/checkin.htm">checkinController</prop>
<prop key="/guestctrl.htm">guestInforController</prop>
<prop key="/reserv.htm">reservController</prop>
<prop key="/guesthistoryctrl.htm">guestHistoryController</prop>
<prop key="/checkout.htm">checkoutController</prop>
<prop key="/basicsetting.htm">basicSettingController</prop>
<prop key="/business.htm">businessCalculationController</prop>
</props>
</property>
</bean> <!-- openSessionInViewInterceptor -->
<bean id="openSessionInViewInterceptor"
class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
<property name="sessionFactory" ref="sessionFactory"/>
</bean> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
</bean> <bean id="paraNameResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
<property name="paramName" value="action"/>
<property name="defaultMethodName" value="init"/>
</bean> <bean name="guestInforUtil" class="com.hotelmaster.home.web.util.GuestInforUtil">
</bean>
<!-- ========================= CONTROLLER DEFINITIONS ========================= -->
<!-- for message now -->
<bean name="userLoginController" class="com.hotelmaster.home.web.login.UserLoginController">
<property name="methodNameResolver">
<ref bean="paraNameResolver"/>
</property>
</bean>
<bean name="homeController" class="com.hotelmaster.action.HomeController">
<property name="methodNameResolver">
<ref bean="paraNameResolver"/>
</property>
</bean> <bean name="frontdeskController" class="com.hotelmaster.action.FrontdeskController">
<property name="methodNameResolver">
<ref bean="paraNameResolver"/>
</property>
<property name="businessService">
<ref bean="businessService"/>
</property>
</bean> <bean name="basicSettingController" class="com.hotelmaster.action.BasicSettingController">
<property name="methodNameResolver">
<ref bean="paraNameResolver"/>
</property>
<property name="businessService">
<ref bean="businessService"/>
</property>
</bean> <bean name="checkinController" class="com.hotelmaster.action.CheckinController">
<property name="methodNameResolver">
<ref bean="paraNameResolver"/>
</property>
<property name="businessService">
<ref bean="businessService"/>
</property>
</bean> <bean name="checkoutController" class="com.hotelmaster.action.CheckoutController">
<property name="methodNameResolver">
<ref bean="paraNameResolver"/>
</property>
<property name="businessService">
<ref bean="businessService"/>
</property>
</bean> <bean name="guestInforController" class="com.hotelmaster.action.GuestInforController">
<property name="methodNameResolver">
<ref bean="paraNameResolver"/>
</property>
<property name="businessService">
<ref bean="businessService"/>
</property>
<property name="guestInforUtil">
<ref bean="guestInforUtil"/>
</property>
</bean> <bean name="reservController" class="com.hotelmaster.action.ReservController">
<property name="methodNameResolver">
<ref bean="paraNameResolver"/>
</property>
<property name="businessService">
<ref bean="businessService"/>
</property>
</bean> <bean name="guestHistoryController" class="com.hotelmaster.action.GuestHistoryController">
<property name="methodNameResolver">
<ref bean="paraNameResolver"/>
</property>
<property name="businessService">
<ref bean="businessService"/>
</property>
</bean> <bean name="businessCalculationController" class="com.hotelmaster.action.BusinessCalculationController">
<property name="methodNameResolver">
<ref bean="paraNameResolver"/>
</property>
<property name="businessService">
<ref bean="businessService"/>
</property>
</bean>
</beans>

3.

 package com.hotelmaster.home.web.login;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController; /**
* Class description goes here.
*
* @author FoGhost
* @Date Mar 21, 2008
*/
public class UserLoginController extends MultiActionController{
/** Logger for this class and subclasses */
protected final Logger logger = Logger.getLogger(UserLoginController.class); public ModelAndView init (HttpServletRequest request,HttpServletResponse response) throws Exception{
return new ModelAndView("userLogin");
//return null;
} public ModelAndView userLogin(HttpServletRequest request,HttpServletResponse response)throws Exception{
String userID=(String) request.getParameter("userID").trim();
String userPass=(String) request.getParameter("userPass").trim();
if(userID.equals("admin")&& userPass.equals("admin") ){
//return new ModelAndView("login");
request.getSession().setAttribute("user", "admin");
response.getWriter().write("{success: true}");
return null;
}else{ response.setContentType("text/json; charset=utf-8");
response.getWriter().write("{success: false,errors:{ reason: '用户名密码错误' }}");
return null;
}
}
}

SpringMVC前置控制器SimpleUrlHandlerMapping配置的更多相关文章

  1. Spring-MVC理解之二:前置控制器

    原文链接:http://www.cnblogs.com/brolanda/p/4265749.html 一.前置控制器配置与讲解 上篇中理解了IOC容器的初始化时机,并理解了webApplicatio ...

  2. spring mvc: 可参数化的视图控制器(在配置中指定jsp文件)MultiActionController/SimpleUrlHandlerMapping/ParameterizableViewController

    spring mvc: 可参数化的视图控制器(在配置中指定jsp文件)MultiActionController/SimpleUrlHandlerMapping/ParameterizableView ...

  3. spring mvc(前置控制器)(转载)

    (此文转载:http://www.cnblogs.com/brolanda/p/4265749.html) 一.前置控制器配置与讲解 上篇中理解了IOC容器的初始化时机,并理解了webApplicat ...

  4. DispatcherServlet--Spring的前置控制器作用简介

    参考网址:http://jinnianshilongnian.iteye.com/blog/1602617 Struts有一个ActionServlet,用来完成前置控制器(分发器)的功能.其实,所有 ...

  5. 淘淘商城之springmvc前端控制器

    一.web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=&qu ...

  6. SpringMVC之二:配置 Spring MVC

    Servlet 3.0规范在2009年12月份就发布了,因此很有可能你会将应用部署到支持Servlet 3.0的Servlet容器之中,如tomcat7.0及以上.在Servlet 3 规范中,可以使 ...

  7. springMVC用法 以及一个简单的基于springMVC hibernate spring的配置

    替代struts 1  web.xml中配置springmvc中央控制器 <?xml version="1.0" encoding="UTF-8"?> ...

  8. JavaEE开发之SpringMVC中的路由配置及参数传递详解

    在之前我们使用Swift的Perfect框架来开发服务端程序时,聊到了Perfect中的路由配置.而在SpringMVC中的路由配置与其也是大同小异的.说到路由,其实就是将URL映射到Java的具体类 ...

  9. Spring-MVC开发步骤(入门配置)

    Spring-MVC开发步骤(入门配置) Step1.导包 spring-webmvc Step2.添加spring配置文件 Step3.配置DispatcherServlet 在web.xml中: ...

随机推荐

  1. 自定义下拉刷新控件-CBStoreHouseRefreshControl

    本文转载至 http://www.cocoachina.com/ios/20141110/10177.html iOS开发自定义刷新CBStoreHouseRefres 介绍 这是一款在Storeho ...

  2. python 基础 7.2 时间格式的相互转换

    #/usr/bin/python #coding=utf-8 #@Time   :2017/11/9 8:55 #@Auther :liuzhenchuan #@File   :时间格式的相互转换.p ...

  3. 【BZOJ1316】树上的询问 点分治+set

    [BZOJ1316]树上的询问 Description 一棵n个点的带权有根树,有p个询问,每次询问树中是否存在一条长度为Len的路径,如果是,输出Yes否输出No. Input 第一行两个整数n, ...

  4. going

  5. 流畅python学习笔记:第二十章:属性描述符:

    在前面一章中介绍了@property的用法,但是存在一个问题,如果我有多个属性想转变成property特性,那不是针对每个都需要实现一个 @propery.setter 和 @property.get ...

  6. Java反射详解(转)

    原文地址:http://www.importnew.com/17616.html 动态语言 动态语言,是指程序在运行时可以改变其结构:新的函数可以被引进,已有的函数可以被删除等在结构上的变化.比如众所 ...

  7. Java for LeetCode 095 Unique Binary Search Trees II

    Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For e ...

  8. [2018-12-18]ABP中的AsyncCrudAppService介绍

    前言 自从写完上次略长的<用ABP入门DDD>后,针对ABP框架的项目模板初始化,我写了个命令行工具Abp-CLI,其中子命令abplus init可以从github拉取项目模板以初始化项 ...

  9. LeetCode:将有序数组转换为二叉搜索树【108】

    LeetCode:将有序数组转换为二叉搜索树[108] 题目描述 将一个按照升序排列的有序数组,转换为一棵高度平衡二叉搜索树. 本题中,一个高度平衡二叉树是指一个二叉树每个节点 的左右两个子树的高度差 ...

  10. px sp dp 手机尺寸