简单的java和jsp 问题!

huangzhong1 2003-09-29 04:47:16
我的java代码是:
package helloworld;

import java.io.*;
public class helloworld
{
public void getString()
{
System.out.println("helloword");
}
}

JSP代码是:
package helloworld;

import java.io.*;
public class helloworld
{
public void getString()
{
System.out.println("helloword");
}
}

运行的结果是:
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 14 in the jsp file: /jsp/new/first.jsp

Generated servlet error:
C:\tomcat\work\localhost\examples\jsp\new\first$jsp.java:63: ')' expected.
out.print(asd.getString(););
请问那里去错了。
...全文
20 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
youandi79 2003-10-01
  • 打赏
  • 举报
回复
java代码改成是:
package helloworld;

import java.io.*;
public class helloworld
{
public String getString()
{
return "helloword";
}
}

JSP代码改成

<html>

<title>MY FIRST JSP</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<jsp:useBean id="asd" scope="erquest" class="hel.helloworld"/>
<%@ page language="java"%>

<%=ads.getString()%>

</body>
</html>
huangzhong1 2003-10-01
  • 打赏
  • 举报
回复
ads是id
ejb99666 2003-09-29
  • 打赏
  • 举报
回复
<% ads.getString();%>什么意思?应该是<%=....%>中间可以放string
zcjl 2003-09-29
  • 打赏
  • 举报
回复
jsp修改如下:

<%@ page language="java"%>
<html>
<head>
<title>MY FIRST JSP</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<jsp:useBean id="asd" scope="request" class="hel.helloworld"/>
<%=ads.getString()%>
</body>
</html>
mtou 2003-09-29
  • 打赏
  • 举报
回复
out.print(asd.getString(););
变成:
out.print(asd.getString());
huangzhong1 2003-09-29
  • 打赏
  • 举报
回复
JSP代码

<html>

<title>MY FIRST JSP</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<jsp:useBean id="asd" scope="erquest" class="hel.helloworld"/>
<%@ page language="java"%>

<% ads.getString();%>

</body>
</html>

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧