[英]How to access model attribute fields in JSP scriptlet?
In my controller I have code like this: 在我的控制器中,我有这样的代码:
List<FeesReceiptIntegrationModel> FRIList = feesReceiptIntegrationService.listInstituteWiseCollectionSummary(model, request);
model.addAttribute("FRIList", FRIList);
I want to access this FRIList and its fields in Scriptlet of JSP page. 我想在JSP页面的Scriptlet中访问此FRIList及其字段。 I tried something like this: 我试过这样的事情:
String fcash = request.getParameter(FRIList.cashamount);
but it does not work. 但它不起作用。
List myMap = (ArrayList) request.getAttribute("FRIList.cashamount");
I don't want to access this via JSTL tags but I would like to access this only in scriptlet. 我不想通过JSTL标签访问它,但我想只在scriptlet中访问它。
Can anybody tell me how this can be achieved? 谁能告诉我如何实现这一目标?
You cant print the values in the list as it is, you need to iterate them after you get the list from the model
. 您无法按原样打印列表中的值,需要在从model
获取列表后对其进行迭代。 As said, 如上所述,
I don't want to access this via JSTL tags but I would like to access this only in scriptlet 我不想通过JSTL标签访问它,但我想只在scriptlet中访问它
<% List<FeesReceiptIntegrationModel > myMap = (ArrayList<FeesReceiptIntegrationModel >) request.getAttribute("FRIList");
for(FeesReceiptIntegrationModel obj : myMap ){
obj.getcashamount(); // your getter method here
}
%>
but it is not advisable to use the scriptlets
, please have a look at How to avoid Java code in JSP files? 但是不建议使用scriptlets
,请看一下如何避免JSP文件中的Java代码?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.