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的更多相关文章

  1. spring 整合struts

    1.例子:未被spring整合 struts.xml 的配置文件 <constant name="struts.enable.DynamicMethodInvocation" ...

  2. SSH开发实践part4:Spring整合Struts

    1 好了,前面spring与hibernate的整合开发我们基本上讲完了,现在要开始服务层的开发,也就是处理事务的action,在这里我们需要引入spring与struts的整合.也就是将action ...

  3. Spring整合Struts的两种方式介绍

    1 使用Spring托管Struts Action 该种方式就是将Struts Action也视为一种Bean交给Spring来进行托管,使用时Struts的配置文件中配置的Action的classs ...

  4. 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 使用自动装配

  5. spring整合struts

    整合目标:使用spring的bean管理struts action service. 整合步骤: 一.加入spring 1.加入spring jar包 2.配置web.xml文件 <contex ...

  6. Spring整合struts的配置文件存放问题

    只使用Spring的时候,我把applicationContext.xml是放在项目的src路径下的,这样使用ClassPathXmlApplicationContext很方便嘛 整合了struts之 ...

  7. 【SSH】Spring 整合 Struts

    添加 spring-struts-3.2.9.RELEASE.jar struts-config.xml 添加 <controller> <set-property property ...

  8. Spring入门(四)— 整合Struts和Hibernate

    一.Spring整合Struts 1. 初步整合 只要在项目里面体现spring和 strut即可,不做任何的优化. struts 环境搭建 创建action public class UserAct ...

  9. Spring整合Struts2框架的第二种方式(Action由Spring框架来创建)(推荐大家来使用的)

    1. spring整合struts的基本操作见我的博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2框架整 ...

随机推荐

  1. 使用XSD校验Mybatis的SqlMapper配置文件(1)

    这篇文章以前面对SqlSessionFactoryBean的重构为基础,先简单回顾一下做了哪些操作: 新建SqlSessionFactoryBean,初始代码和mybatis-spring相同: 重构 ...

  2. Design3:使用HierarchyID构建数据的分层结构

    1,传统的分层结构是父子结构,表结构中有一个ParentID字段自引用表的主键,表示“归属”关系,例如 create table dbo.emph ( ID int not null primary ...

  3. Android入门(五)UI-单位与尺寸、ListView

    原文链接:http://www.orlion.ga/453/ 一.单位与尺寸 布局文件中一共有以下单位供选择:px,pt,dp,sp px:是像素,屏幕中可见的最小元素单位. pt:是磅,1磅等于1/ ...

  4. 自动生成Mapper和Entity工具MybatisGenerator的使用

    新建一个XML文件crmGeneratorConfig.xml,文件具体内容如下.把MybatisGenerator.zip解压出来,把MybatisGenerator文件夹复制到Eclipse安装目 ...

  5. java中有关线程的题目

    1,看一下下面程序错误发生在哪一行! class Test implements Runnable{ public void run(Thread t){ } } 2,输出结果是什么? class T ...

  6. [Node.js] 基于Socket.IO 的私聊

    原文地址:http://www.moye.me/2015/01/02/node_socket-io/ 引子 最近听到这么一个问题:Socket.IO 怎么实现私聊?换个提法:怎么定位到人(端),或者说 ...

  7. java实现将汉字转为拼音

    有时候为了方便操作程序的开发,需要将汉字转为拼音等操作.下面这个是自己结合网上的资料,加上自己在公司项目中的亲自实践.完整的实现了将汉字转为拼音的操作.这个Demo只是负责将其转换,在main方法中测 ...

  8. The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. 错误的原因及解决方案

    异常描述: 数据访问用EF,在数据库中用getdate()设置的默认值,程序中没有赋值. 出现异常. 此错误在百度上在我写此文之前没有多少解决方案,谷歌之等到以下两个有用的页: http://stac ...

  9. Clipboard.js实现复制内容到剪切板

    <script type="text/javascript"> var clipboard1 = new Clipboard('.bt01'); clipboard1. ...

  10. visual studio 2015.3 downloads

    https://www.visualstudio.com/zh-hans/downloads/ visual studio 2015.3 downloads http://download.micro ...