Struts与Spring整合实现用户登录
来源:互联网 发布:c语言中求绝对值 编辑:程序博客网 时间:2024/06/11 11:13
- 步骤:
引入jar文件
引入struts .jar相关文件
spring-core 相关jar文件
spring-web 支持jar包
spring-web-3.2.5.RELEASE.jar 【Spring源码】
struts2-spring-plugin-2.3.4.1.jar 【Struts源码】 - 配置
struts.xml
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"><struts> <package name="default" extends="struts-default"> <action name="checkLogin" class="checkLoginAction"> <!--注意: class属性与以往不同 --> <result name="success">login_suc.jsp</result> <result name="fail">login_fail.jsp</result> </action> </package></struts>
bean-dao.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" 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.xsd"> <bean id="userDao" class="com.ss.dao.UserDaoImpl" scope="singleton"></bean> <!-- 单例,只创建一个实例 --></beans>
bean-service.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" 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.xsd"> <bean id="checkLoginService" class="com.ss.service.CheckLoginService"> <property name="userDao" ref="userDao"></property> </bean></beans>
bean-action.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" 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.xsd"> <bean id="checkLoginAction" class="com.ss.action.CheckLoginAction" scope="prototype"> <property name="checkLoginService" ref="checkLoginService"></property> </bean></beans>
web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app version="3.0" 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_3_0.xsd"> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 2. spring 配置 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/classes/bean-*.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app>
0 0
- Struts与Spring整合实现用户登录
- Struts2与Spring整合,实现登录效果
- 整合Struts 与Spring
- 整合Struts 与Spring
- 整合Struts 与Spring
- struts与spring整合
- spring与struts整合
- Spring与Struts整合
- Spring与Struts整合
- Spring与struts整合
- Spring与Struts整合
- spring 与struts 整合
- struts与spring整合
- Spring与Struts整合
- spring与struts整合
- 粗谈Spring与Struts的整合——从实现的Struts的扩展点上看Spring与Struts的整合
- Spring与Struts如何整合
- Struts与Spring的整合
- AssetBundle.CreateFromFile使用时注意事项
- MFC自定义消息
- Html5 获取手机短信号码
- TCP/IP详解——概述
- golang 中AES加密详解
- Struts与Spring整合实现用户登录
- ruby 文件操作
- google glog 简单使用小结
- string类为什么是final的
- Android--侧滑菜单应用的实现
- apt-get卸载mysql
- Tomcat 虚拟目录配置or Tomcat软连接如何建立?
- Oracle学习笔记(三)
- iOS 获取图片路径的后缀/获取字符串的后缀