迷惑中,求解...........

duwucna 2003-09-11 02:04:55
private String myfunction(String str)
{
if(str==null)
{
str = "";
}
else
{
try {
str = new String(str.getBytes("iso-8895-1"),"gb2312");
}
catch (Exception ex)
{
str=null;
}
}
return str;
}
这个函数在程序中,为什么会出错??
错误:C:\jhome\Tomcat5.0\work\Catalina\localhost\myjsp\org\apache\jsp\reg_jsp.java:43: illegal start of expression
private String myfunction(String str)
...全文
35 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
duwucna 2003-09-11
  • 打赏
  • 举报
回复
出错信息:
org.apache.jasper.JasperException: Unable to compile class for JSP

No Java compiler was found to compile the generated source for the JSP.
This can usually be solved by copying manually $JAVA_HOME/lib/tools.jar from the JDK
to the common/lib directory of the Tomcat server, followed by a Tomcat restart.
If using an alternate Java compiler, please check its installation and access path.
duwucna 2003-09-11
  • 打赏
  • 举报
回复
private String myfunction(String str)这样就错,
private void myfunction(String str)这样才行,why???

lynx1111 2003-09-11
  • 打赏
  • 举报
回复
<%!
public String getStr(String str)
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("GBK");
String temp=new String(temp_t,"ISO8859_1");
return temp;
}
catch(Exception e)
{

}
return "null";
}
%>
cbhyk 2003-09-11
  • 打赏
  • 举报
回复
jsp中定义函数要这样:
<%!
private String myfunction(String str)
{
...
}
%>

<%
String s = ...
String result = myfunction(s); //使用函数
%>

81,091

社区成员

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

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