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. 2.Redis常用命令

    setget 匹配Keykeys *keys na*keys na?e 判断指定的Key是否存在exists key 删除一个或者多个keydel key//删除一个del key1 key2//删除 ...

  2. <C#>找出数组中重复次数最多的数值

    给定一个int数组,里面存在重复的数值,如何找到重复次数最多的数值呢? 这是在某社区上有人提出的问题,我想到的解决方法是分组. 1.先对数组中的所有元素进行分组,那么,重复的数值肯定会被放到一组中: ...

  3. 做网站用UTF-8编码还是GB2312编码?

    经常我们打开外国网站的时候出现乱码,又或者打开很多非英语的外国网站的时候,显示的都是口口口口口的字符, WordPress程序是用的UTF-8,很多cms用的是GB2312. 经常我们打开外国网站的时 ...

  4. Redis基础介绍及安装示例

    1.基本概念 Redis是由Salvatore Sanfilippo(意大利)开发的一个开源的高性能键值存储数据库,于2009年发布第一个版本并与同一年开源,官方站点:http://www.redis ...

  5. 深入理解PHP内核(六)函数的定义、传参及返回值

    一.函数的定义 用户函数的定义从function 关键字开始,如下 function foo($var) { echo $var; } 1.词法分析 在Zend/zend_language_scann ...

  6. 深入理解CSS元素可见性visibility

    × 目录 [1]定义 [2]属性 [3]display[4]JS[5]transition [6]API[7]DEMO 前面的话 visibility属性常见于与display属性的比较中.但实际上, ...

  7. Linq(一)

    Linq是c#设计者们在c#3.0中新添加的语法:查询表达式.使用查询表达式,很多标准查询操作符都能转化成更容易理解的代码,也就是和SQL风格非常接近的代码. 在介绍Linq之前,先介绍下泛型集合IE ...

  8. REST vs SOAP

    REST vs SOAP These information searched from internet most from stackoverflow. Simple explanation ab ...

  9. Azure Automation (1) 入门

    <Windows Azure Platform 系列文章目录> 通过Azure Automation(自动化),开发人员可以自动完成通常要在云环境中执行的手动.长时间进行.易出错且重复性高 ...

  10. 基于caffe的艺术迁移学习 style-transfer-windows+caffe

    这个是在去年微博里面非常流行的,在git_hub上的代码是https://github.com/fzliu/style-transfer 比如这是梵高的画 这是你自己的照片 然后你想生成这样 怎么实现 ...