jsp 값을 contoller updateuser 메소드에 반환 할 때 commonMonth 값이 monthlyMemberSatus 목록의 null 값을 표시 할 때 다음 클래스를 사용 중입니다. 내가 도와 ... 내 코드에서 실수 모르는 나jsp에서 컨트롤러로 목록 값을 보내는 방법
컨트롤러 :
@RequestMapping(value = "/tempOpen",method = {RequestMethod.POST, RequestMethod.GET})
public ModelAndView monthMemberList(@ModelAttribute("commanMonth") CommanMonth commanMonth) {
commanMonth.setMonthlyMemberStatus(dataService.listMonthMember());
return new ModelAndView("hlo","commanMonth",commanMonth);
}
@RequestMapping("/tempClose")
public ModelAndView updateUser(@ModelAttribute("commanMonth") CommanMonth commanMonth) {
System.out.println(month.getMonthlyMemberStatus());
dataService.updateRow(month);
return new ModelAndView("hlo","commanMonth",month);
}
모델 클래스 :
public class CommanMonth {
private List<MonthlyMemberStatus> monthlyMemberStatus;
public List<MonthlyMemberStatus> getMonthlyMemberStatus() {
return monthlyMemberStatus;
}
public void setMonthlyMemberStatus(List<MonthlyMemberStatus> monthlyMemberStatus) {
this.monthlyMemberStatus = monthlyMemberStatus;
}
JSP로 페이지 : hlo.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
${commanMonth}
<form:form modelAttribute="commanMonth" method="post"
action="tempClose.html">
<table width="400px" height="150px">
<c:forEach items="${commanMonth.monthlyMemberStatus}" var="list" varStatus="status">
<tr>
<td><form:label path="monthlyMemberStatus[${status.index}].roomMembers.memberName" >${list.roomMembers.memberName}</form:label></td>
<td><form:input path="monthlyMemberStatus[${status.index}].noOffDays" value="31"/></td>
<%-- <td style="visibility:hidden"><form:input path="li[${status.index}].bookId" value="${list.bookId}" readonly="true"/></td>
<td><form:input path="temp[${status.index}].book" value="hloloo"/></td>
</tr> --%>
</c:forEach>
<tr>
<td></td>
<td><input type="submit" value="Update" />
</td>
</tr>
</table>
</form:form>
</body>
</html>
내가 공공의 ModelAndView updateUser (@ModelAttribute ("commanMonth") CommanMonth commanMonth)하지만 여전히 목록 값이 – Manihtraa
당신이 당신의 네트워크 호출을 확인하실 수 있습니다 null의 경우는, 때를 어떤 데이터를 통과 변경되었습니다 f12> 네트워크 탭> 요청 헤더 –
을 눌러서 f12> 네트워크 탭> 요청 헤더에 어떤 데이터를 첨부했는지 묻습니다. – Manihtraa