spring 整合 struts
struts配置
objectFactory
在struts.xml添加,用spring工厂管理action对象 <constant name="struts.objectFactory" value="spring" />action的class
以前配置action的时候是<action name="xxxx" class="包名.类名" ></action>现在改为 <action name="xxxx" class="id" ></action> id是在spring中配置的action bean的id 通过id访问,才能实现由spring管理action对象spring配置
当出现ConversionNotSupportedException异常时Caused by: org.springframework.beans.ConversionNotSupportedException:
Failed to convert property value of type [java.util.LinkedHashMap] to required type [java.util.Map] for property 'fieldErrors'原因
如果访问这个action的时候,出现这个错误,那是因为,action bean 配置了autowire="byType"
因为,action是继承ActionSupport,ActionSupport里面有一个属性是fieldErrors,并且有seter方法
所以spring会自动装配fieldErrors,spring用java.util.LinkedHashMap去装配java.util.Map,这在jdk里面是向下转型,但是spring显然更安全,会直接抛出ConversionNotSupportedException
解决方案
将spring的自动装配改为autowire="byName"
查看原文:http://139.129.55.235/2016/05/31/spring-%e6%95%b4%e5%90%88-struts/
spring 整合 struts的更多相关文章
- spring 整合struts
1.例子:未被spring整合 struts.xml 的配置文件 <constant name="struts.enable.DynamicMethodInvocation" ...
- SSH开发实践part4:Spring整合Struts
1 好了,前面spring与hibernate的整合开发我们基本上讲完了,现在要开始服务层的开发,也就是处理事务的action,在这里我们需要引入spring与struts的整合.也就是将action ...
- Spring整合Struts的两种方式介绍
1 使用Spring托管Struts Action 该种方式就是将Struts Action也视为一种Bean交给Spring来进行托管,使用时Struts的配置文件中配置的Action的classs ...
- 8 -- 深入使用Spring -- 7... Spring 整合 Struts 2
8.7 Spring 整合 Struts2 8.7.1 启动Spring 容器 8.7.2 MVC框架与Spring整合的思考 8.7.3 让Spring管理控制器 8.7.4 使用自动装配
- spring整合struts
整合目标:使用spring的bean管理struts action service. 整合步骤: 一.加入spring 1.加入spring jar包 2.配置web.xml文件 <contex ...
- Spring整合struts的配置文件存放问题
只使用Spring的时候,我把applicationContext.xml是放在项目的src路径下的,这样使用ClassPathXmlApplicationContext很方便嘛 整合了struts之 ...
- 【SSH】Spring 整合 Struts
添加 spring-struts-3.2.9.RELEASE.jar struts-config.xml 添加 <controller> <set-property property ...
- Spring入门(四)— 整合Struts和Hibernate
一.Spring整合Struts 1. 初步整合 只要在项目里面体现spring和 strut即可,不做任何的优化. struts 环境搭建 创建action public class UserAct ...
- Spring整合Struts2框架的第二种方式(Action由Spring框架来创建)(推荐大家来使用的)
1. spring整合struts的基本操作见我的博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2框架整 ...
随机推荐
- Liferay7 BPM门户开发之39: Form表单提交的ProcessAction处理
在v6.2开始后,需要设置<requires-namespaced-parameters>false</requires-namespaced-parameters> 来避免 ...
- Java基础-接口看下图实现如下接口和类,并完成Adventure中的主方法
package hanqi; public interface CanSwim { void swim(); } package hanqi; public interface CanFly { pu ...
- react-native —— 在Windows下搭建React Native Android开发环境
在Windows下搭建React Native Android开发环境 前段时间在开发者头条收藏了 @天地之灵_邓鋆 分享的<在Windows下搭建React Native Android开发环 ...
- 快速入门系列--WCF--05事务
最近开始WCF相关知识的学习,虽然实际工作中使用公司自己的一套SOA系统,但微软的一套服务架构还是具有很大的参考意义.除了WCF的一些基础使用,相对比较复杂的内容有分布式的事务和通信的安全等,不过基本 ...
- js提取正则中的字符串
代码如下: var results = data.match(/(start=').*?(')/); if (results != null) { console.log(data[0]); }
- tomcat 容器生命周期lifecycle
1.复习java的事件机制 java事件机制包括三个部分:事件.事件监听器.事件源. 事件:一般继承自java.util.EventObject类,封装了事件源对象及跟事件相关的信息. 事件监听器:实 ...
- Deep learning:四十二(Denoise Autoencoder简单理解)
前言: 当采用无监督的方法分层预训练深度网络的权值时,为了学习到较鲁棒的特征,可以在网络的可视层(即数据的输入层)引入随机噪声,这种方法称为Denoise Autoencoder(简称dAE),由Be ...
- 《HelloGitHub月刊》第04期(秋招临近,本期加入了面试相关的项目)
兴趣是最好的老师,而<HelloGitHub> 就是帮你找到兴趣! 因为我比较熟悉python语言,所以月刊中python语言的项目居多,个人能力有限,其他语言涉及甚少,欢迎各路人士加入, ...
- mysql插入日期 vs oracle插入日期
今天做oracle日期插入的时候突然开始疑惑日期是如何插入的. 用框架久了,反而不自己做简单的工作了.比如插入. 通常,新建一个表对象,然后绑定数据,前端form提交,后端getModel后直接mod ...
- 【Swift学习】Swift编程之旅---控制流(九)
Swift提供了类似C语言的流程控制结构,包括可以多次执行任务的for和while循环,基于特定条件选择执行不同代码分支的if和switch语句,还有控制流程跳转到其他代码的break和continu ...