Язык выражения не может найти мою собственность
Кажется, у меня проблема с чтением частных статических переменных на моей странице JSP. Все переменные, кроме статических, могут отображаться на странице JSP, но когда я пытаюсь отобразить статические, выдается следующее исключение:
org.apache.jasper.JasperException: An exception occurred processing [displayResults.jsp] at line [18]
15: </center>
16: <table>
17: <tr>
18: <td>Total Fare for all Stop 1: ${theTrain.stop1_profit}</td>
19: </tr>
20: <tr>
21: <td>Total Fare for all Stop 2: ${theTrain.stop2_profit}</td>
Трассировки стека:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:593)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:482)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
train.control.TrainServlet.doPost(TrainServlet.java:47)
javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Первопричина:
javax.el.PropertyNotFoundException: Property [stop1_profit] not found on type [train.model.Train]
javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:260)
javax.el.BeanELResolver$BeanProperties.access$300(BeanELResolver.java:212)
javax.el.BeanELResolver.property(BeanELResolver.java:347)
javax.el.BeanELResolver.getValue(BeanELResolver.java:92)
org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:110)
org.apache.el.parser.AstValue.getValue(AstValue.java:169)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:702)
org.apache.jsp.displayResults_jsp._jspService(displayResults_jsp.java:139)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
train.control.TrainServlet.doPost(TrainServlet.java:47)
javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Вот эта страница JSP:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<center>
<p>The fare amount to ${theTrain.destination} station from North Avenue station is PHP ${theTrain.current_fare}</p>
<p>Please remember you have to alight at STOP ${theTrain.stop_number}</p>
<hr>
<p>List of Fare Profits</p>
</center>
<table>
<tr>
<td>Total Fare for all Stop 1: ${theTrain.stop1_profit}</td>
</tr>
<tr>
<td>Total Fare for all Stop 2: ${theTrain.stop2_profit}</td>
</tr>
<tr>
<td>Total Fare for all Stop 3: ${theTrain.stop3_profit}</td>
</tr>
<tr>
<td>Total Fare for all Stop 4: ${theTrain.stop4_profit}</td>
</tr>
<tr>
<td>Total Fare for all Stop 5: ${theTrain.stop5_profit}</td>
</tr>
<tr>
<td>Total Fare for all Stop 6: ${theTrain.stop6_profit}</td>
</tr>
</table>
<p>Click <a href="index.html">here</a> to go back to the form. </p>
</body>
</html>
Вот JavaBean:
package train.model;
public class Train {
private String last_name;
private String first_name;
private String destination;
private double current_fare;
private int stop_number;
private static double stop1_profit = 0.00;
private static double stop2_profit = 0.00;
private static double stop3_profit = 0.00;
private static double stop4_profit = 0.00;
private static double stop5_profit = 0.00;
private static double stop6_profit = 0.00;
public String getLast_name() {
return last_name;
}
public void setLast_name(String last_name) {
this.last_name = last_name;
}
public String getFirst_name() {
return first_name;
}
public void setFirst_name(String first_name) {
this.first_name = first_name;
}
public String getDestination() {
return destination;
}
public void setDestination(String destination) {
this.destination = destination;
}
public double getCurrent_fare() {
return current_fare;
}
public void setCurrent_fare(double current_fare) {
this.current_fare = current_fare;
}
public int getStop_number() {
return stop_number;
}
public void setStop_number(int stop_number) {
this.stop_number = stop_number;
}
public static double getStop1_profit() {
return stop1_profit;
}
public static void setStop1_profit(double stop1_profit) {
Train.stop1_profit = stop1_profit;
}
public static double getStop2_profit() {
return stop2_profit;
}
public static void setStop2_profit(double stop2_profit) {
Train.stop2_profit = stop2_profit;
}
public static double getStop3_profit() {
return stop3_profit;
}
public static void setStop3_profit(double stop3_profit) {
Train.stop3_profit = stop3_profit;
}
public static double getStop4_profit() {
return stop4_profit;
}
public static void setStop4_profit(double stop4_profit) {
Train.stop4_profit = stop4_profit;
}
public static double getStop5_profit() {
return stop5_profit;
}
public static void setStop5_profit(double stop5_profit) {
Train.stop5_profit = stop5_profit;
}
public static double getStop6_profit() {
return stop6_profit;
}
public static void setStop6_profit(double stop6_profit) {
Train.stop6_profit = stop6_profit;
}
public void evaluateStop(String stop) {
if (stop.equals("stop1")) {
stop1_profit = stop1_profit + 10.00;
destination = "Quezon Avenue & GMA Kamuning";
current_fare = 10.00;
stop_number = 1;
} else if (stop.equals("stop2")) {
stop2_profit = stop2_profit + 11.00;
destination = "Cubao";
current_fare = 11.00;
stop_number = 2;
} else if (stop.equals("stop3")) {
stop3_profit += 12.00;
destination = "Ortigas & Shaw Boulevard";
current_fare = 12.00;
stop_number = 3;
} else if (stop.equals("stop4")) {
stop4_profit += 13.00;
destination = "Boni Avenue & Guadalupe";
current_fare = 13.00;
stop_number = 4;
} else if (stop.equals("stop5")) {
stop5_profit += 14.00;
destination = "Buendia & Ayala";
current_fare = 14.00;
stop_number = 5;
} else if (stop.equals("stop6")) {
stop6_profit += 15.00;
destination = "Magallanes & Taft Avenue";
current_fare = 15.00;
stop_number = 6;
}
}
}
Когда я попытался удалить языки выражений, которые получают статические переменные, он работает и отображает String last_name; String first_name; String destination; double current_fare; int stop_number;
как это должно. Я не знаю, как я должен отображать эти значения. Я нахожусь в процессе изучения JavaEE и динамических веб-приложений, так что простите меня за этот неубедительный вопрос.