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. ANDROID 推送到底哪家强(转)

    之前在群里有同学问我关于推送的一些问题,解答之后我觉得这个话题还挺有用,因为几乎大部分人都会遇到这个问题,那姑且就写篇文章总结给你们吧. 1. 为什么要用推送? 推送功能可谓是现如今任何一个 App ...

  2. ant 可自动替换友盟渠道、版本号、包名

    可自动替换友盟渠道.版本号.包名 如何集成到我的项目里 前提:了解android官方文档,在项目目录中执行ant debug能打包,比如常见的打包步骤: android update project ...

  3. C#中的new和override(转)

    在衍生类中的方法上使用new和override关键字有何意义,可以通过一系列问题来找到答案.先看一段代码: 1 class Program 2 { 3 static void Main(string[ ...

  4. HNOI2017

    本蒟蒻表示终于把$HNOI2017$全AC了... 万岁! 附上各个题的题解: $DAY1$: $T1$: BZOJ4825: [Hnoi2017]单旋 $T2$: BZOJ4826: [Hnoi20 ...

  5. linux c编程:进程间通信

    进程间的通信包括管道,共享内存,信号量通信,消息队列,套借口(socket)和全双工管道通信 首先来看下管道的用法:管道顾名思义,就如同下水道管道一样,当从管道一端流水到另一端的时候,水流的方向是单方 ...

  6. HBase存储方案设计

    需求描述 将数据记录持久化存储在HBase中,需要支持如下功能: 支持高吞吐量读写操作,实时采集10,000条/秒: 支持动态添加字段: 支持服务端过滤: 支持部分字段修改. 设计方案 按列存储 优点 ...

  7. 利用iOS原生系统进行人脸识别+自定义滤镜(GPUImage)

    人脸识别+滤镜效果(基于GPUImage实现的自定义滤镜) 最近碰到一个好玩的需求.说要客户端这边判定一下是否有人脸.在有的基础上.对相片做进一步的美化滤镜处理. 首先是人脸的识别判定; //将图片对 ...

  8. jQuery+CSS3动画相册特效

    在线演示 本地下载

  9. 0CTF 2017 部分Web的某些不一样的思路

    洒家参加了0CTF 2017,做了一些题目.赛后过了好几天,看网上已经有了一些写得不错的Writeup,这里就写一写洒家的一些不一样的思路. 一些不错的Writeup https://ctftime. ...

  10. Hadoop- NameNode和Secondary NameNode元数据管理机制

    元数据的存储机制 A.内存中有一份完整的元数据(内存meta data) B.磁盘有一个“准完整”的元数据镜像(fsimage)文件(在namenode的工作目录中) C.用于衔接内存metadata ...