使用usebean直接发送类的数据

时间:2014-12-18 15:30:19

标签: java jsp usebean

我有一个setting.java课程,在本课程中,我从一个文件中读取数据,并希望在我的jsp:useBean页面中将此数据与index.jsp一起使用。

这个类代码如下:

public class setting {

private  boolean setstatus=false;
private  String  title="Test";

public boolean changeheader(String text) {
    return true;
}

public boolean settitle(String  text) {
    return true;
}

public void getTitle() throws IOException{
    BufferedReader br ;
    try {
        br = new BufferedReader(new FileReader("C:\\Users\\Farshid\\workspace\\STPT\\WebContent\\file\\title.txt"));
        this.title = br.readLine();
        System.out.println("\nline: " + this.title + "\n");
        br.close();
    } catch (FileNotFoundException e1) {
        e1.printStackTrace();
        System.out.println("Error");
    }

}
}

这是我的index.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=UTF-8">
 <title>

 </title>
</head>
<body>
 <jsp:useBean id="settitle" class="com.stpt.project.setting" scope="page">
 <jsp:getProperty property="title" name="settitle" />
 </jsp:useBean>
</body>
</html>

这些是我的错误:

    type Exception report

    message Cannot find any information on property '*' in a bean of type 'com.stpt.project.setting'

   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 '*' in a bean of type 'com.stpt.project.setting'
    org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:824)
    org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1081)
    org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1125)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2377)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2429)
    org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1380)
    org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1181)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2377)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2429)
    org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2435)
    org.apache.jasper.compiler.Node$Root.accept(Node.java:474)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2377)
    org.apache.jasper.compiler.Generator.generate(Generator.java:3517)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:250)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

最后我的IDE是eclipse,我的服务器是apache tomcat7.0。

0 个答案:

没有答案