- 浏览: 939494 次
- 性别:
- 来自: 江西上饶
文章分类
- 全部博客 (460)
- p.spring (56)
- p.maven (20)
- p.ant (17)
- p.jee (18)
- p.jse (33)
- p.ofbiz (31)
- p.软件工程 (8)
- p.struts2 (5)
- p.hibernate (5)
- linux (25)
- 设计模式 (2)
- p.javascript (11)
- 硬件 (1)
- p.jsp (2)
- p.windows批处理 (1)
- 操作系统问题 (5)
- 算法 (1)
- p.mysql (7)
- p.sql (5)
- p.c (1)
- google产品 (0)
- 内存 (1)
- p.struts (1)
- p.freemarker (7)
- p.css (4)
- p.log4j (10)
- p.html (3)
- 淘宝产品 (0)
- 其他 (3)
- 编译器 (0)
- svn (4)
- p.spring.security (11)
- 图形 (0)
- p.xml (1)
- p.ssh (0)
- p.jquery (4)
- p.jdbc (3)
- p.flex (0)
- p.c++ (0)
- p.c#Net (0)
- p.assembly (0)
- p.sqlserver (0)
- p.其他 (3)
- p.webwork (21)
- p.wap (12)
- p.cglib (1)
- p.jee服务器 (11)
- windows (2)
- p.iphone (1)
- p.java.分布式与集群 (2)
- p.ibatis (16)
- p.eclipse (5)
- 架构 (2)
- http协议 (5)
- 我的个人标准 (2)
- 多线程 (1)
- 奇怪问题 (5)
- p.jira (13)
- p.httpclient (1)
- 服务器.apache (11)
- 安全防范 (1)
- p.PODAM (1)
- p.junit (16)
- fop (2)
- 硬盘安装 (1)
- powerdesigner (0)
- 单元测试 (1)
- apache commons (4)
- tomcat+apache集群 (10)
- 各类诡辩 (1)
- 安卓 (8)
- qvod (1)
- java编程基础知识考试考点及答案 (0)
- 工作总结 (4)
- oracle (0)
- spring的util工具 (3)
- json (2)
- maven (3)
- jms (19)
- p.bat (3)
- hadoop (2)
- git (3)
- nginx (1)
- p.移动开发 (1)
- shiro (3)
- 游戏破解 (1)
- react-native (7)
- ios开发 (1)
- webmagic (6)
- socks5 (1)
最新评论
-
weituotian:
说的不好,没人看的
公司系统中的菜单功能和权限功能 -
石不易:
非常详细的注解~
绑定端口和IP,Listen 与VirtualHost指令 -
spring_springmvc:
spring mvc demo教程源代码下载,地址:http: ...
spring mvc -
liyixing1:
PandaDONG 写道谢谢你啊,我已经下下来了,只是还有很多 ...
jira war安装 -
liyixing1:
PandaDONG 写道谢谢你啊,我已经下下来了,只是还有很多 ...
jira war安装
我使用这样无法传入
我们直接写List是会报错的,因为springmvc不知道怎么初始化list对象,因此它是会报错的
这个时候可以借助加一层模型,因为第一层(方法参数),是直接调用class的实例化来初始化的。
另外可以改用数组,比如
或者直接用list的子类
@requestMapping("/test") public String getTest(List<User> users){ return "test"; }
我们直接写List是会报错的,因为springmvc不知道怎么初始化list对象,因此它是会报错的
org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.util.List]: Specified class is an interface at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:102) at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.createAttribute(ModelAttributeMethodProcessor.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor.createAttribute(ServletModelAttributeMethodProcessor.java:81) at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:104) at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:79) at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:157) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:124) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:748) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:684) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
这个时候可以借助加一层模型,因为第一层(方法参数),是直接调用class的实例化来初始化的。
E{ List<F> flist; getter/setter; }
Controller{ public execute(E e){ List<F> list = e.getFlist(); --- } }
另外可以改用数组,比如
Controller{ public execute(String[] es){ } }
或者直接用list的子类
@RequestMapping(value = "/classify/listTreeAndSelect.html") public void listAndSelect(HttpServletRequest request, ModelMap model, UnifiedUser user,ArrayList<Long> selectIds) { }
发表评论
-
Spring 定时任务,cron表达式,@Scheduled cron表达式
2016-04-25 15:48 5266一个cron表达式有至少6 ... -
Unable to locate Spring NamespaceHandler for XML schema namespace
2015-09-23 14:00 2290org.springframework.beans.facto ... -
关于使用s.url jstl的上下文
2015-08-16 13:28 884比如 [@s.url '/'/]index.html?cote ... -
Spring 属性占位符配置器 PropertyPlaceholderConfigurer
2015-08-02 12:43 2047<!-- 属性配置文件读 ... -
FactoryBean接口
2014-09-30 14:05 868实现了FactoryBean接口的bean不是简单的一个bea ... -
国际化之MessageSourceAware和MessageSourceAccessor
2014-01-06 23:13 2820先看接口MessageSourceAware 该接口的注释中 ... -
spring 惯例优先原则
2013-07-22 09:46 1166惯例优先原则(convention over configur ... -
ant path匹配
2013-07-22 09:40 2135spring和ant path实现相关的主要类有两个 org. ... -
springmvc action方法中参数具有@ModelAttribute与不具有的区别
2012-12-14 09:36 4082在springmvc的参数解析中,发现具有@ModelAttr ... -
util包
2012-12-05 13:50 1068spring的util基本上都在springframework ... -
url,请求相关帮助类UrlPathHelper
2012-11-29 11:18 2487org.springframework.web.util.Ur ... -
整站国际化方案
2012-11-28 17:46 1074当前常见的实现方式,主要由两种方案实现 1.通过locale ... -
spring的三种注入方式
2012-11-20 17:30 18291.通过bean的property子元 ... -
spring AnnotationUtils 注解工具
2011-12-08 11:27 1270spring AnnotationUtils 注解工具 -
GenericCollectionTypeResolver,用于获取list或者map等元素的类型
2011-12-07 16:17 1272GenericCollectionTypeResolver,用 ... -
属性编辑器
2011-12-05 18:19 1055我自定义了一个类型,然后设置了一个属性编辑器,注册的class ... -
iframe下面的session问题
2011-12-04 19:52 5270在写iframe完成长连接获取上传状态的时候,有两次请求,一次 ... -
mvc之类的驱动原理
2011-12-01 09:34 1059<mvc:annotation-driven /> ... -
Couldn't access current invocation
2011-10-20 20:44 1858做了一个aop的日志记录器,但是在运行的时候出现了日志信息 服 ... -
DEBUG -- CLOSE BY CLIENT STACK TRACE
2011-10-20 10:28 27590在单元测试测试环境下主要参数两个错误信息: 1.java.la ...
相关推荐
前端使用jquery向后台传递数组类型的参数,Java后台直接通过List类型接收,会发现无法取到参数。
首先, 我需要在你心里建立起 Spring MVC 的基本概念. 基于 Spring 的 Web 应用程序接收到 http://localhost:8080/hello.do(事实上请求路径是 /hello.do) 的请求后, Spring 将这个请求交给一个名为 helloController ...
spring mvc拦截器,过滤json数据中的null值,将null变成空字符串,内含截图,及jar包
org.springframework.web.context.ContextLoaderListener <filter-name>encodingFilter org.springframework.web.filter.CharacterEncodingFilter <param-name>encoding ...
主要为大家详细介绍了Spring MVC参数自动绑定List的解决方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
基于spring mvc注解开发的ajax项目实例,通过对注解@ResponseBody的应用,实现ajax局部刷新功能,java代码端返回Map,Integer,User,List等对象,在jsp页面通过$.each(data,function(index,entity) { });...
弃用了struts,用spring mvc框架做了几个项目,感觉都不错,而且使用了注解方式,可以省掉一大堆配置文件。本文主要介绍使用注解方式配置的spring mvc,之前写的spring3.0 mvc和rest小例子没有介绍到数据层的内容,...
本例子用到Spring MVC , Jdbc, JSon, Gson 等等技术,Spring Servlet 配置,Spring中ClassPathXmlApplicationContext类的简单使用,Jdbc的配置与数据库的读取,List与json的转换,java对象使⽤Gson转json字符串null...
NULL 博文链接:https://vernonchen163.iteye.com/blog/1899769
主要介绍了SpringMVC接收复杂集合对象(参数)代码示例,举接收List、List、List<Map>>、User[]、User(bean里面包含List)几种较为复杂的集合参数,具有一定参考价值,需要的朋友可以了解下。
* Spring DATA: used for the list pagination ( size, page, oderBy) * JPA: Java Persistence API * Tiles: in order to create the template (header, body, menu, footer) * Ehcache: in order to optimize the ...
本文主要给大家介绍了关于Angular.js前台传list数组由后台spring MVC接收数组的相关内容,分享出来供大家参考学习,下面话不多说,来一起看看详细的介绍吧。 在开发中有时候需要在前台自定义对象,然后把对象封装在...
Spring MVC 分步教程 Spring MVC 教程 - 链接 更新 完成项目! 我成功地重新启动了教程,并从头到尾使用了版本控制。 查看已完成项目的 git 存储库。 运行 springapp ant build deploy 启动您的 tomcat 网络...
该项目采用springmvc+spring+springjdbc框架+mysql框架实现 包含了jdbcTemplate的使用。queryForList,匿名内部类方式查询。 将List,Object>>转换成List方法。
* Spring DATA: used for the list pagination ( size, page, oderBy) * JPA: Java Persistence API * Tiles: in order to create the template (header, body, menu, footer) * Ehcache: in order to optimize the ...
待办事项列表测试 演示: : 旧的测试项目。 使用 Spring MVC (3.2.2.RELEASE) 构建以在 Google App Engine 中运行。
We'll start by creating a web application using Spring MVC, Spring Data, the World Bank API for some statistics on different countries, and MySQL database. Moving ahead, you'll build a RESTful web ...
新建一个maven项目,并设置pom文件,设置当前项目为web项目,将packaging的属性值设置为war方式,添加spring mvc的依赖包, spring-webmvc(4.3.6),分别添加插件,jdk和tomcat 4.0.0 com.qfedu Days17...
注释的类标记为包含请求处理程序的Spring MVC的Bean @RestController -标记注释类为@Controller豆,并增加了@ResponseBody序列化返回的结果信息 @ Configuration-将带注释的类标记为定义bean的Java配置 @Service-...