<jsp:useBean>问题
a.jsp源码:<%@pagecontentType="text/html"pageEncoding="gb2312"%><jsp:useBeanid="h"scope=...
a.jsp源码:<%@page contentType="text/html" pageEncoding="gb2312"%>
<jsp:useBean id="h" scope="application" class="d"/>
<%--h.setHello("jsp:useBean");--%>
<%=h.getHello()%>
d.java源码://package MyTest;
public class d
{String h="当然";
public void setHello(String n){h=n;}
public String getHello(){return h;}
}
结果报错:Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /a.jsp(2,0) The value for the useBean class attribute d is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1204)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1117)
是怎么回事?谁能随便给我一个能成功运行的<jsp:useBean>程序。只要能切实体会到<jsp:useBean>的作用。或者指出上面那个错误原因 展开
<jsp:useBean id="h" scope="application" class="d"/>
<%--h.setHello("jsp:useBean");--%>
<%=h.getHello()%>
d.java源码://package MyTest;
public class d
{String h="当然";
public void setHello(String n){h=n;}
public String getHello(){return h;}
}
结果报错:Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /a.jsp(2,0) The value for the useBean class attribute d is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1204)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1117)
是怎么回事?谁能随便给我一个能成功运行的<jsp:useBean>程序。只要能切实体会到<jsp:useBean>的作用。或者指出上面那个错误原因 展开
3个回答
展开全部
你这个报错是说没有javabean是不可获得的
usebean标签没用过,bean是一个类,只要引入就行了
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"梁悄%>
<%@ page import="困搏MyBeans.TestJB"%>汪渣祥
<%
Vector vt=(Vector)request.getAttribute("result");
TestJB tj=new TestJB();
tj.setb1(v.get(0).toString());
%>
这样就调用了bean
usebean标签没用过,bean是一个类,只要引入就行了
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"梁悄%>
<%@ page import="困搏MyBeans.TestJB"%>汪渣祥
<%
Vector vt=(Vector)request.getAttribute("result");
TestJB tj=new TestJB();
tj.setb1(v.get(0).toString());
%>
这样就调用了bean
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询