spring 服务器遇到了阻止它完成请求的意外情况
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43077139/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The server encountered an unexpected condition that prevented it from fulfilling the request
提问by Mohanraj
I am trying to display Data from DB.But Shows error as
我正在尝试显示来自 DB 的数据。但显示错误为
The server encountered an unexpected condition that prevented it from fulfilling the request
服务器遇到了阻止它完成请求的意外情况
Exception
例外
org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/pages/Detail.jsp at line 14
11: </head>
12: <body>
13:
14: <c:forEach var="x" items="${prdt}">
15: <table>
16: <img src="resources/Images/${x.id}.png"/>
17: <td>"
MY JSP
我的 JSP
<c:forEach var="x" items="${prdt}">
<table>
<img src="resources/Images/${x.id}.png"/>
<td>
<c:out value="${x.product_Name}"/></td>
<td>
<c:out value="${x.descripction}"/></td>
<td>
<c:out value="${x.price}"/></td>
<td>
<c:out value="${x.mfg_Date}"/>
</td>
</table>
</c:forEach>
My Controller
我的控制器
public ModelAndView productDtails(@PathVariable int id)
{
ModelAndView model=new ModelAndView("Detail");
model.addObject("prdt",pd.getById(id));
return model;
}
My DAO IMpl
我的 DAO IMpl
public Product getById(int id)
{
Session session=sessionFactory.openSession();
Product p=(Product) session.get(Product.class, id);
session.close();
return p;
}
Any Idea????
任何的想法????
采纳答案by developer
You can't iterate over prdtobject i.e., you are using forEachtag and prdtis not a Listobject, so to solve the issue simply remove <c:forEach var="x" items="${prdt}">or else you need to return a listobject from your Contoller.
您不能迭代prdt对象,即,您使用的是forEach标记而prdt不是List对象,因此要解决该问题,只需删除即可<c:forEach var="x" items="${prdt}">,否则您需要list从控制器返回一个对象。
Your JSP looks as below (after removing <c:forEach):
您的 JSP 如下所示(删除后<c:forEach):
<table>
<img src="resources/Images/${x.id}.png"/>
<td>
<c:out value="${prdt.product_Name}"/></td>
<td>
<c:out value="${prdt.descripction}"/></td>
<td>
<c:out value="${prdt.price}"/></td>
<td>
<c:out value="${prdt.mfg_Date}"/>
</td>
</table>
回答by KleberBH
My issue was resolved by adding the below in the model
通过在模型中添加以下内容解决了我的问题
[AllowHtml]
public string Description { get; set; }
C# MVC for POST
用于 POST 的 C# MVC

