首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

jsp异常提示

2013-09-11 
jsp错误提示jsp代码HTML codehtmlheadtitleusing jsp:setProperty/title/headbodytable bord

jsp错误提示
jsp代码

HTML code
<html><head><title>using jsp:setProperty</title></head><body><table border="1" align="center">    <tr><th class="title">        using jsp:setProperty</table><jsp:useBean id="entry" class="bean.SaleEntry"></jsp:useBean><jsp:setProperty property="itemID" name="entry" value='<%=request.getParameter("itemID") %>'/><jsp:setProperty property="numItems" name="entry" value='<%=request.getParameter("numItems") %>'/><jsp:setProperty property="discountcode" name="entry" value='<%=request.getParameter("discountcode") %>'/><br/><table border="1" align="center">    <tr class="colored"><th>Item ID</th><th>unit price</th><th>number ordered</th><th>total price</th></tr>    <tr align="right">        <td><jsp:getProperty name="entry" property="itemID" /></td>        <td><jsp:getProperty name="entry" property="itemCost"/></td>        <td><jsp:getProperty property="numItems" name="entry"/> </td>        <td><jsp:getProperty property="totalCost" name="entry"/></td>    </tr></table></body></html>

----------------
bean.SaleEntry的代码:
package bean;

public class SaleEntry {
private String itemID = "unknown";
private double discountcode = 1.0;
private int numItems = 0;

public String getItemID() {
return itemID;
}
public void setItemID(String itemID) {
this.itemID = itemID;
}
public double getDiscountcode() {
return discountcode;
}
public void setDiscountcode(double discountcode) {
this.discountcode = discountcode;
}
public int getNumItems() {
return numItems;
}
public void setNumItems(int numItem) {
this.numItems = numItem;
}

public double getItemCost(){
double cost = 0.0;
if (itemID.equals("a1234"))
cost = 12.99*getDiscountcode();
else
cost = -9999;
return (roundToPennies(cost));
}
private double roundToPennies(double cost) {

return (Math.floor(cost*100)/100.0);
}

public double getTotalCost(){
return(getItemCost()*getNumItems());
}
}
---------------------
错误提示:
HTTP Status 500 - 

--------------------------------------------

type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

org.apache.jasper.JasperException: An exception occurred processing JSP page /SaleEntry.jsp at line 12

9: </table>
10: <jsp:useBean id="entry" class="bean.SaleEntry"></jsp:useBean>
11: <jsp:setProperty property="itemID" name="entry" value='<%=request.getParameter("itemID") %>'/>
12: <jsp:setProperty property="numItems" name="entry" value='<%=request.getParameter("numItems") %>'/>
13: <jsp:setProperty property="discountcode" name="entry" value='<%=request.getParameter("discountcode") %>'/>
14: <br/>
15: <table border="1" align="center">


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)


org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause 

org.apache.jasper.JasperException: java.lang.IllegalArgumentException
org.apache.jasper.runtime.JspRuntimeLibrary.handleSetProperty(JspRuntimeLibrary.java:667)
org.apache.jsp.SaleEntry_jsp._jspService(SaleEntry_jsp.java:76)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause 

java.lang.IllegalArgumentException
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.jasper.runtime.JspRuntimeLibrary.handleSetProperty(JspRuntimeLibrary.java:665)
org.apache.jsp.SaleEntry_jsp._jspService(SaleEntry_jsp.java:76)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.


--------------------------------------------

Apache Tomcat/6.0.13
------------
要怎么解决非法参数的问题?

[解决办法]

探讨
引用:

引用:
引用:

引用:
numItems改为字符串类型吧,request.getParameter()方法中取出来的都是字符串

是的,你可以通过Integer.parseInt(" ")方法将字符串转换为对应的整形数据,但是……

我的异常网推荐解决方案:An exception occurred processing JSP page,http://www.myexception.cn/j2se/33144.html
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

热点排行