- 浏览: 92909 次
- 性别:
- 来自: 上海
最新评论
-
mthhk:
彩笔写上面博客
jquery dataTable ajax -
liuweihug:
推荐这个博客看看。Jquery DataTable基于Twit ...
jquery dataTable ajax -
dfwang:
daxiaoli123 写道ant 怎么搞代码统计啊需要使用第 ...
可持续集成测试 -
daxiaoli123:
ant 怎么搞代码统计啊
可持续集成测试 -
dfwang:
daxiaoli123 写道楼主如果包有依赖怎么办啊你的意思是 ...
可持续集成测试
该部分的环境搭建基于Spring Security URL的拦截方式
stripes-1.5.6
spring-framework-3.0.5.RELEASE
spring-security-3.0.5.RELEASE
登陆页面:index.jsp
登陆成功后跳转的页面:
web.xml
messages_zh_CN.properties
commons-logging.properties
log4j.properties
config/applicationContext-common.xml
User.java
LoginActionBean
LogoutActionBean
stripes-1.5.6
spring-framework-3.0.5.RELEASE
spring-security-3.0.5.RELEASE
登陆页面:index.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head><title>index</title></head> <body> <h1>index.jsp</h1> <p>${sessionScope.SPRING_SECURITY_LAST_EXCEPTION.message}</p> <form action="/example/j_spring_security_check" method="post"> <table> <tr> <td>Username:</td> <td><input type="text" name="j_username" /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="j_password" /></td> </tr> <tr> <td colspan="2"> <input name="submit" type="submit"/> </td> </tr> </table> </form> </body> </html>
登陆成功后跳转的页面:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>homepage</title> </head> <body> 首页<br> </body> </html>
web.xml
<?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/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- Spring Configuration begin--> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:config/applicationContext-*.xml</param-value> </context-param> <!-- Spring Configuration end--> <!-- encoding begin--> <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> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <session-config> <session-timeout>60</session-timeout> </session-config> <!-- encoding end--> <!-- Spring security Filter end--> <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Spring security Filter end--> <!-- stripes begin --> <filter> <display-name>Stripes Filter</display-name> <filter-name>StripesFilter</filter-name> <filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class> <init-param> <param-name>ActionResolver.Packages</param-name> <param-value>com.examples.action</param-value> </init-param> <!-- Spring integrate Stripes begin--> <init-param> <param-name>Interceptor.Classes</param-name> <param-value> net.sourceforge.stripes.integration.spring.SpringInterceptor </param-value> </init-param> <!-- Spring integrate Stripes end--> </filter> <filter-mapping> <filter-name>StripesFilter</filter-name> <url-pattern>*.jsp</url-pattern> <dispatcher>REQUEST</dispatcher> </filter-mapping> <filter-mapping> <filter-name>StripesFilter</filter-name> <servlet-name>StripesDispatcher</servlet-name> <dispatcher>REQUEST</dispatcher> </filter-mapping> <servlet> <servlet-name>StripesDispatcher</servlet-name> <servlet-class>net.sourceforge.stripes.controller.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>StripesDispatcher</servlet-name> <url-pattern>*.action</url-pattern> </servlet-mapping> <!-- stripes end --> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
messages_zh_CN.properties
AbstractUserDetailsAuthenticationProvider.badCredentials=您无权访问目标资源,请输入正确的密码!
commons-logging.properties
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
log4j.properties
log4j.rootLogger = debug, CONSOLE log4j.addivity.org.apache = true log4j.appender.CONSOLE = org.apache.log4j.ConsoleAppender log4j.appender.Threshold = DEBUG log4j.appender.CONSOLE.Target = System.out log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c.%t() line:%L - %m %n
config/applicationContext-common.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:security="http://www.springframework.org/schema/security" 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-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"> </beans>
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:security="http://www.springframework.org/schema/security" 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-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"> <security:http auto-config="true" > <security:intercept-url pattern="/index.jsp*" filters="none"/> <!-- <security:logout invalidate-session="true" logout-url="/example/j_security_logout" logout-success-url="/index.jsp"/>--> <security:form-login login-page="/index.jsp" default-target-url="/Login.action" /> <security:custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrencyFilter" /> <security:session-management session-authentication-strategy-ref="concurrentsessionControl" /> <security:intercept-url pattern="/**" access="ROLE_USER"/> </security:http> <security:authentication-manager> <security:authentication-provider> <security:user-service> <security:user name="user" password="user" authorities="ROLE_USER"/> </security:user-service> </security:authentication-provider> </security:authentication-manager> <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="basename" value="classpath:messages_zh_CN"></property> </bean> <bean id="concurrencyFilter" class="org.springframework.security.web.session.ConcurrentSessionFilter"> <property name="sessionRegistry" ref="sessionRegistry" /> <property name="expiredUrl" value="/Loginfailure.jsp" /> </bean> <bean id="concurrentsessionControl" class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy"> <constructor-arg name="sessionRegistry" ref="sessionRegistry" /> <property name="maximumSessions" value="1" /> </bean> <bean id="sessionRegistry" class="org.springframework.security.core.session.SessionRegistryImpl" /> </beans>
User.java
public class User { private String username; private String password; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } }
LoginActionBean
public class LoginActionBean extends User implements ActionBean { private ActionBeanContext context; private static Log logger = LogFactory.getLog(LoginActionBean.class); public ActionBeanContext getContext() { return this.context; } public void setContext(ActionBeanContext context) { this.context=context; } //取得user private void initUser(){ logger.debug("LoginActionBean initUser logic is starting........"); Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); if(principal instanceof UserDetails){ logger.debug("principal is an User Object ..."); this.setUsername(((UserDetails)principal).getUsername()); this.setPassword(((UserDetails)principal).getPassword()); }else{ logger.debug("principal instanceof User is false.................."); } logger.debug("LoginActionBean initUser logic is end........"); } @DefaultHandler public Resolution login(){ logger.debug("LoginActionBean login logic is starting........"); initUser(); logger.debug("Login username is : "+this.getUsername()+" | user password is : "+ this.getPassword()); logger.debug("LoginActionBean login forward to homepage........"); return new ForwardResolution("/homepage.jsp"); } }
LogoutActionBean
public class LogoutActionBean extends User implements ActionBean { private ActionBeanContext context; private static Log logger = LogFactory.getLog(LogoutActionBean.class); public ActionBeanContext getContext() { return this.context; } public void setContext(ActionBeanContext context) { this.context=context; } @DefaultHandler public Resolution logout(){ logger.debug("LogoutActionBean login logic is starting........"); logger.debug("Login username is : "+this.getUsername()+" | user password is : "+ this.getPassword()); logger.debug("LogoutActionBean login forward to index.jsp........"); context.getRequest().getSession().invalidate(); SecurityContextHolder.clearContext(); return new ForwardResolution("/index.jsp"); } }
发表评论
-
configuration
2012-04-26 15:10 930无聊写点sample,供以后抄袭 JNDI方式 1、Spr ... -
可持续集成测试
2012-04-24 13:26 2359最近在搞可持续集成测试,顺便写个小例子以后方便参考 目录结构 ... -
运用RUP 4+1视图方法进行软件架构设计
2012-02-07 13:54 1050http://www.ibm.com/developerwor ... -
代理模式,动态代理
2011-12-09 16:31 971一、先看个普通代理模式的例子: 1.接口类 package ... -
jqGrid ajax 互搞,json object 互搞
2011-11-29 16:52 4771今天玩了玩jqGrid,贴点代码出来,以后方便copy jqG ... -
读properties文件
2011-11-24 11:25 1143太无聊了,写个读properties文件的类方便以后直接cop ... -
TOMCAT 配置及性能优化
2011-11-15 11:05 1074参考资料:1.http://blog.sina.com.cn/ ... -
AOP面向切面编程
2011-11-11 13:40 888转载: http://wayfarer.cnblogs.com ... -
ThreadPool
2011-11-07 17:07 1023最近面试被问到这个问题,正好找个线程池的实现代码,温习一下 ... -
Spring 事务管理
2011-10-26 09:31 973文章转自:【http://blog.c ... -
HttpServletRequestWrapper 学习
2011-10-20 09:17 1534使用过滤器不能改变HttpServletRequest对象的参 ... -
JNDI Sample
2011-10-13 09:06 904public class TestJb ... -
Build an Apache Wink REST service(一)
2011-10-12 09:30 1259Apache Wink service configurati ... -
jquery dataTable ajax
2011-09-16 15:32 15555dataTable 插件的相关api: http://www. ... -
BodyTagSupport 学习
2011-09-15 10:52 1235BodyTagSupport类的方法: 编写标签对应的实现类时 ... -
DataTables Ajax 回调函数
2011-09-08 12:53 7062<!DOCTYPE HTML PUBLIC &quo ... -
Mybatis 学习转
2011-09-07 14:46 1874Mybatis缓存系列 在sqlMap文件中加入cacheMo ... -
Spring3MVC+ajax
2011-07-11 17:03 738随便玩了玩springMVC3 + ajax 帖下代码和目录结 ... -
quartz的时间设置
2011-06-22 15:52 1202格式: [秒] [分] [小时] [日] [月] [周] [年 ... -
转:解决 java.util.MissingResourceException: Can't find bundle for base name com...c
2011-05-10 14:25 2406转:解决 java.util.MissingResourceE ...
相关推荐
stripes1.5.7+spring3.1.1+MyBatis3.1.1完整框架 本工程代码已完成了Oracle,MySQL,MSSQL2005三种数据库物理分页方言,并测试可用。 本代码集成了xheditor-1.2.1在线编辑器远程抓取图片功能。 集成了excel导入...
这个是本人从官网下载下来的一个简单的网上宠物商店的小小项目,整合了spring、mybatis和stripes
如何实现spring3.0.5与Stripes1.5.6(类似Struts框架)的整合。 如何使用mybatis3.0.5框架。 压缩包说明: 文件解压后有mybatis(可直接导入eclipse运行的项目)和mybatis-3.0.5-bundle.zip(官方压缩包) 官方压缩包里的...
包含文档~ 快速开发~ 快速布局页面~适用web开发~轻量级,体积小
Java Web层框架之比较—比较JSF、Spring MVC、Stripes、Struts 2、Tapestry和Wicket.doc
和我们熟悉 Struts 1 和 Struts 2 类似,Stripes 同样是一种展示层框架,用于快速构建web程序。在使 用Struts 1,WebWork 和 Struts 2 等框架的时候,通常需要大量额外的 XML 配置,当一个项目达到 一定规模的的时候...
和我们熟悉 Struts 1 和 Struts 2 类似,Stripes 同样是一种展示层框架,用于快速构建web程序。在使用Struts 1,WebWork 和 Struts 2 等框架的时候,通常需要大量额外的 XML 配置,当一个项目达到一定规模的的时候,...
Stripes是一种新的简易的web框架势,本篇介绍在Stripes中下载excel表格
Stripes视图框架demo 资源可用性毋庸置疑 下载的童鞋给点辛苦分不要介意
stripes入门,Stripes是一个以让程序员的web开发简单而高效为准则来设计的基于动作的开源Java web框架。本文将介绍Stripes与其它如Struts之类基于动作的框架的区别和其提供的一些存在于Ruby on Rails之中的简单性。
Make developing web applications in Java easy...Make the Stripes ramp up time for a new developer less than 30 minutes Make it really easy to extend Stripes, without making you configure every last thing
改写至mybaits提供的示例程序,将Stripes实现改为maven管理的,mybatis+spring mvc项目,使用sitemesh装饰。提供完整的宠物商店,支持开发模式和应用模式,只需要修改web.xml文件中的spring.profiles.active属性为...
Stripes 快速入门 pdf 中文版 下载
NULL 博文链接:https://jayung.iteye.com/blog/1882363
有关设置开发环境的一般 Stripes 信息、指南和帮助,请参阅 Github 存储库。Stripes-core 文档了一个使用 Stripes Connect 连接到后端服务的组件的简单示例。 通过示例展示了件——有些是连接的,有些不是——如何...
In this 100-page book, you will find that Stripes provides a very simple learning path, where you do not need to understand the entire framework in order to use it. The concept of this book is exactly...
NULL 博文链接:https://rainyear.iteye.com/blog/1539513
Wordpress Blue Stripes模板
Wordpress Neon Stripes模板