4
我有一個窗體在我的視圖中發送對象到我的控制器,但問題是,如果我發送超過256個對象:發送從視圖到控制器的對象列表:限於256個對象
org.springframework.beans.InvalidPropertyException: Invalid property 'followers[256]' of bean class [org.myec3.portalgen.plugins.newsletter.dto.FollowerFileDto]: Index of out of bounds in property path 'followers[256]'; nested exception is java.lang.IndexOutOfBoundsException: Index: 256, Size: 256
所以我想知道爲什麼這樣的限制,我發現這個話題:https://stackoverflow.com/a/24699008/4173394
但它似乎爲我工作(可能是一個壞的使用從我)。
這裏是我的結構: 我的觀點被稱爲createUpdate.vm並張貼我的形式是這樣的:
<form id="createFollowerFileForm" method="post" action="#route("followerFileController.upsertFollowerFile")" enctype="multipart/form-data" class="form_styled">
我的功能upsertFollowerFile在FollowerFileController:
@InitBinder
public void initBinder(WebDataBinder dataBinder) {
// this will allow 500 size of array.
dataBinder.setAutoGrowCollectionLimit(500);
}
@Secured({ "ROLE_SUPER_ADMIN_PORTALGEN", "ROLE_CUSTOMER_PORTALGEN", "ROLE_ADMIN_PORTALGEN", "ROLE_WRITER_PORTALGEN" })
public String upsertFollowerFile(
@ModelAttribute(value = "followerFile") FollowerFileDto followerFileDto,
BindingResult result, ModelMap model, HttpServletRequest request) {
而且我的課FollowerFileDto:
public class FollowerFileDto {
private String title;
private Long followerId;
private boolean isDeletable;
private List<FollowerDto> followers;
public FollowerFileDto() {
this.followers = new ArrayList<FollowerDto>();
}
正如你可以在我的cont滾筒,我嘗試用@InitBinder註釋設置超過256個允許的對象(500),但它根本不起作用。 InitBinder函數永遠不會被調用。我做錯了什麼嗎? 感謝您的回答;)
你可以嘗試的initBinder無擔保註解。這不應該爲upserFollowerFile? – 2014-12-02 15:31:50
我試圖評論@Secured,但我有同樣的問題。 – 2014-12-02 15:58:44
你真的需要multipart/form-data嗎? – 2014-12-02 18:52:23