J2EE 0.1—spring整合struts方法及纠错(原创)

本文介绍了一个使用 Struts 框架进行配置的例子,并展示了如何通过 Struts 与 Spring 框架整合来实现用户登录功能。具体包括了 Struts 的配置文件结构、Spring Bean 的定义方式及 Spring 与 Struts 结合时的关键配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

xml 代码
  1. xml version="1.0" encoding="UTF-8"?>  
  2. >  
  3.   
  4. <struts-config>  
  5.     <data-sources />  
  6.     <form-beans>  
  7.         <form-bean name="userLoginForm"  
  8.             type="org.perfect.struts.form.UserLoginForm" />  
  9.   
  10.     form-beans>  
  11.   
  12.     <global-exceptions />  
  13.     <global-forwards />  
  14.     <action-mappings>  
  15.   
  16.   
  17.         <action    
  18.             input="/userLogin.jsp"  
  19.             path="/userLogin"  
  20.             scope="request"  
  21.             name="userLoginForm"  
  22.             type="org.springframework.web.struts.DelegatingActionProxy"  
  23.                
  24.             >  
  25.         action>  
  26.     action-mappings>  
  27.   
  28.   
  29.     <message-resources  
  30.         parameter="org.perfect.struts.ApplicationResources" />  
  31.     <plug-in  
  32.         className="org.springframework.web.struts.ContextLoaderPlugIn">  
  33.         <set-property property="contextConfigLocation"  
  34.             value="/WEB-INF/applicationContext.xml" />  
  35.     plug-in>  
  36.        
  37.        
  38. struts-config>  
  39.   
xml 代码
  1. xml version="1.0" encoding="UTF-8"?>  
  2. <beans  
  3.     xmlns="http://www.springframework.org/schema/beans"  
  4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  5.     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">  
  6.   
  7.     <bean id="user" class="org.perfect.struts.vo.User">bean>  
  8.        
  9.      <bean name="/userLogin" class="org.perfect.struts.action.UserLoginAction" scope="singleton">  
  10.           <property name="user">  
  11.                <ref bean="user" />  
  12.            property>  
  13.      bean>  
  14.   
  15. beans>  
<html:form action="/userLogin"> </html:form>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值