【发布时间】:2011-07-28 02:58:15
【问题描述】:
我在数据库中有 2 个表(机场和中途停留)。 我写了一个 SQL 连接查询,得到一个包含两个表中的字段的结果集。 为了映射结果,我创建了一个自定义对象“VbResult”。 (DB中没有这个域对象对应的表)
请在下面找到域对象、控制器和视图的代码: 当我调用主页时,我得到了异常,尽管我在 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>
【问题讨论】:
标签: java jsp spring-mvc jstl el