springMVC pass an array of objects acquired model jq

The problem online is no answer, there are two possibilities;

First, I use this method really stupid normal people are not going to do this;

Second, I'm stupid. . . .

The following solutions

//后台代码如下
public String plant(Model model){
        Iterable<LandStatus> land = landStatusService.findAll();
        Iterator<LandStatus> iter = land.iterator();
        UserList user = (UserList)session.getAttribute("user");
        List<LandStatus> list = new ArrayList<LandStatus>();
        while(iter.hasNext()) {
            LandStatus t = iter.next();
            
            if(t.getUserId() == user.getId())
                list.add(t);
                
        }
        model.addAttribute("lands", list);
        return "cropsGrow/plant";
    }
//前端获取数据
<c:forEach items="${lands}" var ="i" varStatus="status">
        <input type="hidden"  value="${i.landId}=${i.seedId}=${i.currentSeason}=${i.lastSeason}=${i.isInsect}=${i.growStage}" id="val${i.landId}">
        
    </c:forEach>

<script type="text/javascript">12; i <=1i =the(for

       $ (function () {
            ;i++){
                console.log("#val :",$("#val"+i).val());
            }
        });

</script>

This approach is really stupid stupid stupid is not an ordinary very stupid stupid stupid enough not work

Guess you like

Origin www.cnblogs.com/zengguoqiang/p/10963140.html