spring mvc 绑定两个对象进行表单提交
//form表单是可以提交多个对象的
/**
* 保存简历
* @param bean 简历信息
* @param jobIntention 求职意向
* @return
*/
@Logined
@RequestMapping(value = "/job_resume_add", method = RequestMethod.POST)
public ModelAndView doAdd(JobResume bean,JobIntention jobIntention) {
Timestamp now =DateHelper.now();
bean.setRecordTime(now);
jobResumeService.insert(bean);
jobIntention.setRecordTime(now);
jobIntention.setJobResumeId(bean.getId());
jobIntentionService.insert(jobIntention);
ModelAndView mav = new ModelAndView("redirect:cresume.do?id="+bean.getId());
return mav;
}
前台jsp表单中的字段为两个对象的所有字段,如果两个对象中有相同的字段,只设置一个就可以,假如需要不同的值,可以单独设置该字段的值,controller中接收方法也须改动,
public ModelAndView doAdd(JobResume bean,JobIntention jobIntention,@RequestParam("id") Integer id) {
//TODO 业务代码
//单独处理id值
}//方法中的 @RequestParam("id") Integer id 可以是单个,也可以是多个,根据业务需求设置声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇:没有了
- 下一篇:没有了
