前台form截取部分
直播课
录播课
线下课
-----------------------------------------------
以上两个对象处于同一个表单中
----------------------------后台方法
此时仅仅接收LessonResouce是能够接收到的
public Lesson save(HttpServletRequest request,
// @Param("::lesson") Lesson lesson,
@Param("::lessonResource") List reses //
) {
int id = 0;
Lesson lesson = new Lesson();
if (!isEmpty(lesson.getId())) {
id = lesson.getId();
lesson.setDtUpdateTime(new Date());
lesson.setIntUserId(AuthorityHolder.getUser().getId());
lesson.setTxtUserName(AuthorityHolder.getUser().getTxtReName());
if (lesson.getTxtLessonDesc() != null)
lesson.setTxtLessonDesc(lesson.getTxtLessonDesc().replace(""", "'"));
lessonService.Update(lesson);
} else {
lesson.setDtCreateTime(new Date());
lesson.setIntUserId(AuthorityHolder.getUser().getId());
lesson.setTxtUserName(AuthorityHolder.getUser().getTxtReName());
lesson.setTxtStatus("未上架");
if (lesson.getTxtLessonDesc() != null)
lesson.setTxtLessonDesc(lesson.getTxtLessonDesc().replace(""", "'"));
id = lessonService.Save(lesson);
}
-------------------------
问题:
当**同时**接lesson 跟 lessonResource的时候** 会抛异常**,**所以怎样在一个表单中接收两个对象?**
异常如下java.lang.ClassCastException: **java.util.ArrayList cannot be cast to java.util.Map**
at org.nutz.mapl.impl.convert.ObjConvertImpl.injectObj(ObjConvertImpl.java:192)
at org.nutz.mapl.impl.convert.ObjConvertImpl.inject(ObjConvertImpl.java:81)
2016-6-3 1:41:49.574 DEBUG [http-apr-8080-exec-7] Found mapping for [POST] path=/lesson/save : LessonController.save(LessonController.java:69)
at org.nutz.mapl.impl.convert.ObjConvertImpl.convert(ObjConvertImpl.java:65)
2016-6-3 1:41:49.574 DEBUG [http-apr-8080-exec-7] Get 'lessonController'<class admin.teachart.controllers.lesson.LessonController>
at org.nutz.mapl.Mapl.maplistToObj(Mapl.java:34)
at org.nutz.mvc.adaptor.injector.ObjectNavlPairInjector.get(ObjectNavlPairInjector.java:53)
at org.nutz.mvc.adaptor.AbstractAdaptor.adapt(AbstractAdaptor.java:256)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:28)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:196)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2508)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2497)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)