eclipse新建一个springsecurity项目
来源:互联网 发布:java国际象棋棋盘棋子 编辑:程序博客网 时间:2024/06/11 13:27
eclipse新建一个springsecurity项目
第一步,打开eclipse,点击新建-->web项目
第二步,导入jar包
1. 加入 Spring 的 jar 包
2. 加入 SpringSecurity 的 jar 包
spring-security-acl-3.1.0.M1.jar
spring-security-config-3.1.0.M1.jar
spring-security-core-3.1.0.M1.jar
spring-security-taglibs-3.1.0.M1.jar
spring-security-web-3.1.0.M1.jar
第三步,在web.xml中添加contextLoader和springsecurity的配置
<span style="font-size:12px;"> <!-- 配置 ContextLoaderListener 加载applicationContext.xml--> <context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!-- 配置springsecurity 的filter 其中的helloFilter是spring容器中装配的bean--><filter><filter-name>helloFilter</filter-name><filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class></filter><filter-mapping><filter-name>helloFilter</filter-name><url-pattern>/*</url-pattern></filter-mapping></span>
第四步,在src下新建一个HelloFilter类,实现Filter接口,用于测试
@Component为HelloFilter添加注解,将其注入到spring容器中
@Componentpublic class HelloFilter implements Filter{@Overridepublic void destroy() {// TODO Auto-generated method stubSystem.out.println("filter destory...");}@Overridepublic void doFilter(ServletRequest arg0, ServletResponse arg1,FilterChain arg2) throws IOException, ServletException { System.out.println("[HelloFilter]doFilter...");}@Overridepublic void init(FilterConfig arg0) throws ServletException {System.out.println("filter init...");}
第五步,配置spring的配置文件(eg:applicationContext.xml)
applicationCintext.xml
<span style="font-weight: normal;"><p><span style="font-size:18px;"><beans xmlns="http://www.springframework.org/schema/beans"</span></p><p><span style="font-size:18px;">xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:security="http://www.springframework.org/schema/security"xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"></span></p></span>
a),在applicationcontext.xml中添加扫描注解
<span style="font-weight: normal;"><context:component-scan base-package="com.shawsuper.securityfilter.HelloFilter"></context:component-scan></span>
第六步,在eclipse的tomcat上部署运行,当你访问你的项目时,如果控制台控制台输出[HelloFilter]doFilter...即为新建成功
0 0
- eclipse新建一个springsecurity项目
- eclipse新建一个struts2项目
- 在eclipse中新建一个web项目
- eclipse环境下,新建一个Manven项目
- 实战之eclipse新建一个mavenWeb项目
- eclipse如何新建一个maven项目
- Eclipse下新建Android项目碰到的一个小问题
- 关于eclipse for java ee 如何新建一个javaWeb项目
- Eclipse新建一个web项目没有自动生成web.xml
- eclipse 新建 struts项目
- eclipse新建maven项目
- 新建一个struts2项目
- 新建一个 Maven 项目
- 新建一个 Android 项目
- 新建一个vue项目
- 新建一个Android项目
- vue 新建一个项目
- 新建一个vue项目
- Linux 系统获取系统时间
- Unity的摄像机拉近拉远和旋转脚本实现
- 1.6的锁优化(适应性自旋/锁粗化/锁削除/轻量级锁/偏向锁)
- http报文中字段解析
- css编写九阴真经弹窗效果
- eclipse新建一个springsecurity项目
- Retrofit请求数据对错误以及网络异常的处理
- 图像处理库dlib的配置
- c hash
- linux下搭建git服务器
- SDC时序约束(1)- create_clock
- 多态与多态案例
- 初学单片机时总结的想法及一些程序
- matplotlib 可视化 —— 移动坐标轴(中心位置)