如何在另一个控制器方法中访问一个控制器方法的表单 bean 的值?

问题描述

在下面的例子中,我有 2 个控制器方法

控制器方法1有一个excel表(有员工id,员工姓名作为列)作为输入,它读取excel表并提取员工id 进入clobdata并显示应用程序中的excel内容

控制器方法 2 需要这个 clobdata(employee id) 作为输入来执行一些数据库插入。

我应该使用 2 个控制器(实时我有一些复杂的代码涉及这 2 个控制器,只是为了理解目的,我给出了上面的例子) 有什么方法可以将控制器 1 中的 clobdata 存储到某个变量中,然后在控制器 2 中检索和使用

//Controller method 1
@RequestMapping(value = "/first",method = { RequestMethod.GET,RequestMethod.POST })
public ModelAndView getFirst(@modelattribute("Form1") Form1 formA,BindingResult result,HttpServletRequest request,ModelMap map) {
try {
.......
.......
//consider this line contains the code for processing an input excel file 
//and extract all the EMPLOYEE ID as clobData into a result form as
//resultForm.getEmpClobData()   
formA.setEmpClobData(resultForm.getEmpClobData());
ResponseWithErrorMsg<Form1> spResp = empservice.displayEmployeeDetails(formA);
.......
.......
}}


//Controller method 2
@RequestMapping(value = "/second",method = {RequestMethod.GET,RequestMethod.POST})
public ModelAndView getSecond(@modelattribute("Form1") Form1 formA,HttpServletResponse response) {
try {
.......
.......
formA.setEmpClobData("here i want to pass the clobData extracted form the above controller");
ResponseWithErrorMsg<Form1> spResp = empservice.insertEmployeeInDatabase(formA);
.......
......
}}

请针对这种情况提出任何解决方案。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)