Struts2与Spring整合,实现登录效果
2017-11-16 15:50
302 查看
1.导jar包(第一部分:struts2 第二部分spring 第三部分 struts2-spring-plugin-2.3.32.jar)
2.创建两个配置文件 struts.xml ,applicationContext.xml
3.在web.xml文件中添加第一个 spring监听 (spring-web) 第二部分 struts2过滤器(contextConfigLocation是配置applicationContext.xml路径,不写我们可以将它复制放在WEB-INF文件夹下)
4.写xml登录页面(success.jsp与error.jsp就不在这里写了);写action(继承 ActionSupport)
5.实例化action(在applicationContext.xml中)
<bean id="loginAction" class="org.hp.action.LoginAction"></bean>
6. 修改struts.xml配置(class调用applicationContext.xml中class对应的id)
<struts>
<package name="struts" namespace="/" extends="struts-default">
<action name="dologin" class="loginAction" method="login">
<result name="success">success.jsp</result>
<result name="error">error.jsp</result>
</action>
</package>
</struts>
总结:到此我们就完成了Struts2与Spring的简单整合,实现登录的demo效果!!!
2.创建两个配置文件 struts.xml ,applicationContext.xml
3.在web.xml文件中添加第一个 spring监听 (spring-web) 第二部分 struts2过滤器(contextConfigLocation是配置applicationContext.xml路径,不写我们可以将它复制放在WEB-INF文件夹下)
4.写xml登录页面(success.jsp与error.jsp就不在这里写了);写action(继承 ActionSupport)
5.实例化action(在applicationContext.xml中)
<bean id="loginAction" class="org.hp.action.LoginAction"></bean>
6. 修改struts.xml配置(class调用applicationContext.xml中class对应的id)
<struts>
<package name="struts" namespace="/" extends="struts-default">
<action name="dologin" class="loginAction" method="login">
<result name="success">success.jsp</result>
<result name="error">error.jsp</result>
</action>
</package>
</struts>
总结:到此我们就完成了Struts2与Spring的简单整合,实现登录的demo效果!!!
相关文章推荐
- Spring3.x_Struts2.x_Hibernate3.x整合之OpenSessionInView的实现
- shiro学习:shiro整合springweb项目实现用户登录和退出
- Struts2整合jQuery实现ajax异步登录
- spring boot整合Shiro实现单点登录的示例代码
- spring cloud整合thymeleaf,实现简单登录
- spring boot整合Shiro实现单点登录
- springboot整合shiro登录失败次数限制功能的实现代码
- struts2整合Spring2.5验证登录
- SpringBoot整合Shiro实现登录认证的方法
- struts2实现简易的登录注册效果
- Struts2,Spring,jquery实现的登录例子
- 在maven环境下 基于Struts2 spring hibernate用户登录及查询整合案例
- spring整合spring-data-redis和spring-session-data-redis通过shiro实现单点登录
- Struts2整合Hibernate3实现用户登录功能
- Spring2.5+Struts2+Jpa(Hibernate实现)整合之一
- Spring整合Hibernate实现登录
- Spring2.5+Struts2+Jpa(Hibernate实现)整合之二
- Spring整合Struts2实现多文件上传及下载
- Struts2实现简单的登录效果
- Shiro整合Spring实现登录验证和授权之入门