javabean例子出错 望指点~
本人刚学习javabean 写了个小程序
BeanTest。java:
package olympics;
public class BeanTest {
String name;
public BeanTest(){}
public void setName(String value)
{name=value;}
public String getName()
{return name;}
}
useBeanEx。jsp:
<html>
<%@page contentType= "text/html ";charset=gb2312 %>
<%@page import= "olympics.* " %>
<head> <title> useBean.jsp </title> </head>
<body>
<%
BeanTest test=new BeanTest();
test.setName( "WANG ");
%>
<%=test.getName() %>
</body>
</html>
觉得没有错误可是报错一直,代码如下:
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: /WebRoot/useBeanEx.jsp(2,0) Unterminated <%@ page tag
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:132)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:504)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1426)
org.apache.jasper.compiler.Parser.parse(Parser.java:133)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:215)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:167)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
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.10 logs.
--------------------------------------------
Apache Tomcat/6.0.10
[解决办法]
她说你JSP第2行写错了,应该是要空格的
[解决办法]
<%@page contentType= "text/html ";charset=gb2312 %>
<%@page import= "olympics.* " %>
<html>
<head> <title> useBean.jsp </title> </head>
<body>
<%
BeanTest test=new BeanTest();
test.setName( "WANG ");
%>
<%=test.getName() %>
</body>
</html>
请这样写!!!!
[解决办法]
修改后好像也一样的代码哦,没看出来哪里不同
[解决办法]
<%@page contentType= "text/html ";charset=gb2312 %>
改成
<%@page contentType= "text/html;charset=gb2312 " %>
把引号移后面去~~
[解决办法]
500的错误是服务器的内部错误.
你的javabean不是这样写的,javabean是可以自动生成的,不用自己写的.
自动生成的javabean是通过在jsp也面中调用.
利用 <jsp:useBean> 来调用,肯定成功,能够实现你的功能.
[解决办法]
试试楼上的看看
[解决办法]
<%@page contentType= "text/html ";charset=gb2312 %>
改成
<%@page contentType= "text/html;charset=gb2312 " %>
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html