我在数据库中有2个表(机场和中途停留)。 我编写了一个SQL连接查询,得到一个包含两个表中字段的结果集。 为了映射结果,我创建了一个Custom对象'VbResult'。 (DB中没有与该域对象对应的表)
请在下面找到Domain对象,Controller和View的代码: 当我调用主页时,我得到了异常,尽管我在VbResult类中有字段ressrc。
(或)使用自定义对象作为VbResult是错误的 - 只是为了View,没有表存在?
我被困了很长时间..我在这里失踪的是什么!请告诉我!
提前致谢
javax.el.PropertyNotFoundException:在com.datacaliper.vbuddy.domain.VbResult类型中找不到属性'ressrc'
域对象:VbResult
public class VbResult implements java.io.Serializable{
private static final long serialVersionUID = -3606761414209638631L;
private Integer resid;
private String resairline;
private String resemail;
private String ressrc;
private String resdes;
//private String res_airline;
public VbResult(){ }
public VbResult(Integer id, String airline, String email,
String source, String destination) {
this.resid= id;
this.resairline = airline;
this.resemail = email;
this.ressrc = source;
this.resdes = destination;
}
public Integer getId() {
return this.resid;
}
public void setId(Integer id) {
this.resid = id;
}
public String getAirline() {
return this.resairline;
}
public void setAirline(String airline) {
this.resairline = airline;
}
public String getEmail() {
return this.resemail;
}
public void setEmail(String email) {
this.resemail = email;
}
public String getSource() {
return this.ressrc;
}
public void setSource(String source) {
this.ressrc = source;
}
public String getDestination() {
return this.resdes;
}
public void setDestination(String destination) {
this.resdes = destination;
}
}
控制器代码:
@Controller
@RequestMapping({"/","/main"})
public class MainController {
protected static Logger logger = Logger.getLogger("controller");
@Resource(name="PostService")
private PostService postService;
@RequestMapping(value = "/home", method = RequestMethod.GET)
public String getStopovers(Model model) {
logger.debug("Received request to show all Posts");
// Retrieve all posts by delegating the call to PostService
List<VbResult> stops = postService.getAll();
// Attach persons to the Model
model.addAttribute("stops", stops);
return "homepage";
}
}
JSPPage
<c:forEach items="${stops}" var="stop">
<tr>
<td><c:out value="${stop.ressrc}" />
</td>
<td><c:out value="${stop.resdes}" />
</td>
</tr>
</c:forEach>
答案 0 :(得分:2)
javax.el.PropertyNotFoundException:在com.datacaliper.vbuddy.domain.VbResult类型中找不到属性'ressrc'
它基本上告诉我们在类上使用名为getRessrc()
的getter方法,并且具有完全限定名com.datacaliper.vbuddy.domain.VbResult
。
事实上,没有这样的方法。你称之为getSource()
。相应地修复您的JSP代码。
<c:out value="${stop.source}" />
修复此问题后您将获得PropertyNotFoundException
上的新resdes
现在应该自我解释;)