こんばんは。アプリケーションにコントローラーがあります:
@Controller
public class LoginSearchController {
//List to store data from resultHTML method
List<Cars> listCars = null;
@Autowired
private EducationWebServiceInterface educationWebService;
//This method render jsp page for user and create model for resultHTML
@RequestMapping(value="/search", method=RequestMethod.GET)
public String search(FormBackingObjectSearch fbos, Model model) {
model.addAttribute("fbosAttributes", fbos);
return "search";
}
// This method get name form form back object and use it for fetchCarsByNameService method
// After if something found it stores it in listofSerchObjects and after listofSerchObjects stores it in listForm List
@RequestMapping(value="/result", method=RequestMethod.GET)
public String resultHTML(@RequestParam String name,
@ModelAttribute("fbosAttributes") FormBackingObjectSearch fbos,
BindingResult bindingResut, Model model) throws Exception {
listCars = new ArrayList<Cars>();
List<Cars> listofSerchObjects = null;
listofSerchObjects = educationWebService.fetchCarsByNameService(dateConvertation(fbos.getName()));
model.addAttribute("findAttributes", listofSerchObjects);
listCars.addAll(listofSerchObjects);
return "search";
}
//This method fetch data from listForm to make Excel document form the list
@RequestMapping(value="/result.xls", method=RequestMethod.GET)
public String resultXLS(Model model) throws Exception {
if(listCars == null || listCars.size() == 0) {
throw new NullPointerException("ArrayList<FormDate> formDateList is empty list");
} else {
model.addAttribute("findAttributesXls", listForm);
}
return "xlspage";
}
}
コントローラーで何が起こるか:
ユーザーは、Search
検索したい車の名前を入力するページに移動し(私の場合)、ボタンをクリックした後FIND
--> リクエストは に送信され/result
ます。この メソッドは、サービス レイヤーからresultHTML
呼び出して、特定の名前に対応するデータを取得し、それを jsp ページにレンダリングします。それからデータを取得すると、すべてのデータが他のリストに追加されます。fetchCarsByNameService
listofSerchObjects
listofSerchObjects
fetchCarsByNameService
listCars
--> 次のステップでは、jsp ページにすべてのデータがレンダリングされると、ボタンが表示されますSAVE AS EXCEL
。何が起こるか: ユーザーがこのボタンをクリックすると (ユーザーが望む場合)、[ /result.xls
AND TAKE ALL THE DATA FROM listCars
] に進み、Excel ファイルに保存されます。
Web アプリケーションで複数のユーザーが同じ jsp ページから異なるコンピューターで作業する場合、 どのようlistCars
に動作するか非常に興味があります。データベースから抽出された最後のデータが保存されるのが怖いです.user1がそれをExcelファイルにレンダリングしたい場合、user2が最後に検索を行う場合、user2からのデータを取得します。あなたが思うこと???アドバイスお願いします。ありがとうございました