我需要使用jsp jstl来渲染jsp中的所有java bean属性。 我使用弹簧mvc。 下面是春季代码的一部分。如何使用jstl填充jsp中的所有java bean属性
@RequestMapping(method=RequestMethod.POST)
public ModelAndView processForm(@ModelAttribute(value="FORM") UploadForm form,BindingResult result) throws Exception{
String filePath = System.getProperty("java.io.tmpdir") + "/" + form.getFile().getOriginalFilename();
ModelAndView model = new ModelAndView("view");
List<Customer> customerList=null;//Customer is POJO file
if(!result.hasErrors()){
ProcessUploadedFile processUploadedFile = new ProcessUploadedFile(form, filePath);
processUploadedFile.putUploadedFileToServer(form,filePath);
customerList= ProcessUploadedFile.readWithCsvBeanReader(filePath);
}
model.addObject("customerList", customerList);//add list of customers in object. all customer data need to be render in jsp
return model;
}
JSP JSTL代码:
<c:forEach var="customer" items="${customerList}">
<tr>
<td><c:out value="${customer.hit_time_gmt}"/></td>
<td><c:out value="${customer.service}"/></td>
<td><c:out value="${customer.accept_language}"/></td>
<td><c:out value="${customer.date_time}"/></td>
<td><c:out value="${customer.visid_high}"/></td>
<td><c:out value="${customer.visid_low}"/></td>
.
.
.
.
</tr>
</c:forEach>
其实有角落找寻在POJO 300个属性并手动写属性等是非常繁琐的。
我想要一些循环的方式来获取所有的属性值是jsp使用jstl或可能是其他方式。 请分享你的提示!
感谢