I have 2 tables in the database (airports and stopovers). I wrote a SQL join query get a result set that has fields from both the tables. In order to map the result, i created a Custom object 'VbResult'. (There is no table in the DB corresponding to this domain object)
Please find below code for Domain object, Controller and the View: When i invoke the home page i get the exception, though i have the field ressrc in VbResult class.
(or) Is it wrong to use a custom object as VbResult - just for the sake of View , for which no table exists?
I am stuck for a long time.. What is that I am missing here! Please let me know!
Thanks in advance
javax.el.PropertyNotFoundException: Property 'ressrc' not found on type com.datacaliper.vbuddy.domain.VbResult
Domain Object: 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.resemai开发者_StackOverflow中文版l;
}
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 Code:
@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>
javax.el.PropertyNotFoundException: Property 'ressrc' not found on type com.datacaliper.vbuddy.domain.VbResult
It's basically telling that there's no getter method with the name getRessrc()
on the class with the full qualified name com.datacaliper.vbuddy.domain.VbResult
.
And indeed, there's no such method. You've called it getSource()
. Fix your JSP code accordingly.
<c:out value="${stop.source}" />
The new PropertyNotFoundException
on resdes
which you would get after fixing this should now be self-explaining enough ;)
精彩评论