Computer.java
package test;
public class Computer {
private String sCpu;
private String sPrice;
public String getSCpu() {
return sCpu;
}
public void setSCpu(String cpu) {
sCpu = cpu;
}
public String getSPrice() {
return sPrice;
}
public void setSPrice(String price) {
sPrice = price;
}
}
computer.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'computer.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%if(request.getParameter("cpu")!=null&request.getParameter("price")!=null){
String a=request.getParameter("cpu");
String b=request.getParameter("price"); %>sdf
<jsp:useBean id="cb" scope="page" class="test.Computer"/>
<%=a %><%=b %>
<jsp:setProperty name="cb" property="sCpu" value="<%=a %>" />
<jsp:setProperty name="cb" property="sPrice" value="<%=b %>" />
<jsp:getProperty name="cb" property="sCpu" />
<jsp:getProperty name="cb" property="sPrice" />
<%} %>
<form name="exception" method="post" action="computer.jsp ">
<input name="cpu" type="text" value="55">
<br>
<input name="price" type="text" value="66">
<br>
<input type=submit value="submit">
<br>
</body>
</html>
老是提示
Cannot find any information on property 'sCpu' in a bean of type 'test.Computer'
type Exception report
message Cannot find any information on property 'sCpu' in a bean of type 'test.Computer'
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Cannot find any information on property 'sCpu' in a bean of type 'test.Computer'
org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:804)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1158)
org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1122)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
org.apache.jasper.compiler.Node$Root.accept(Node.java:464)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Generator.generate(Generator.java:3594)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:250)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:570)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:356)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.17 logs.
不间断还会报另一种错误:
HTTP Status 500 - java.lang.ClassNotFoundException: org.apache.jsp.computer_jsp
type Exception report
message java.lang.ClassNotFoundException: org.apache.jsp.computer_jsp
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.computer_jsp
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:176)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:368)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
java.lang.ClassNotFoundException: org.apache.jsp.computer_jsp
java.net.URLClassLoader$1.run(URLClassLoader.java:372)
java.net.URLClassLoader$1.run(URLClassLoader.java:361)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:360)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:131)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:62)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:171)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:368)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.17 logs.
实在搞不出来,求解大神!
------解决思路----------------------
是不是命名规则有问题?
sCpu 改成cpu试试,重写get,set方法