`
hiskyrisa
  • 浏览: 36116 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类

Exception:JSP用foreach迭代list时出错,页面解析出错

阅读更多
HTTP ERROR 500
Problem accessing /mvc/student/getList. Reason: 

    The class 'java.lang.String' does not have the property 'studentId'.

Caused by:
javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property 'studentId'.
	at javax.el.BeanELResolver.getBeanProperty(BeanELResolver.java:579)

 StudentController代码如下:

@RequestMapping("getList")
	public ModelAndView getList() {
		ModelAndView mav = new ModelAndView();
		List<Student> list = studentService.getList(null);
		mav.addObject("list",list);
		mav.setViewName("studentList");
		return mav;
	}

 studentList.jsp代码如下:

<c:forEach var="st" items="${list} ">
<tr>
	<td>${st.studentId}</td>
	<td>${st.name}</td>
	<td>${st.sex}</td>
	<td>${st.home}</td>
	<td>操作</td>
</tr>	
</c:forEach>

问题出在foreach标签的items上,{list}之后多了一个空格。只能自认手贱,敲多了一个空格。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics