在JSP函数中如何输出
是否函数中就不能输出吗,有什么其它方法
我的老是报错<%!
String func_aa(String abc)
{
out.print("select");
return("a");
}
%>-----------------------------------------------------------
org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: -1 in the jsp file: nullGenerated servlet error:
    [javac] Compiling 1 source fileC:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\test_jsp.java:25: cannot resolve symbol
symbol  : variable out 
location: class org.apache.jsp.test_jsp
out.print("a");
        ^
1 error

解决方案 »

  1.   

    你是不是多了个!号啊
    <%
    String func_aa(String abc)
    {
    out.print("select");
    return("a");
    }
    %>
      

  2.   

    out对象是jsp隐含对象,只能在<%  %>或<%=  %>中用
    <%!   %>中不能用的
      

  3.   

    一楼:<%   %>中能再定义函数吗?不要乱说
      

  4.   

    方法改一下,传个out进去
    String func_aa(JspWriter out,String abc)
    {
    out.print("select");
    return("a");
    }调用时
    <%
    String aa=func_aa(out,"welshem");
    %>
      

  5.   

    不好意思,看错题义了
    看看下面的例子<%!
    String hello(){
        return "您好,朋友,欢迎进入JSP世界,^_^";
    }
    %><html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>JSP例程 - 在JSP中定义函数</title>
    </head>
    <body>
    <%=hello()%>
    </body>
    </html>
      

  6.   

    JSP里不能定义JAVA函数,out是JSP内制对象!~out可以输出.但是JSP不能定义JAVA函数!~~楼上的见解正确,UP!!!
      

  7.   

    thisyear(小丑): JSP里能在<%!   %>定义JAVA函数!
    只是<%!   %>里定义的函数与Jsp转成Servlet后的_jspService函数是同级别的,所以不能用在_jspService中定义的jsp隐含对象(又叫内置对象)而<%  %>或<%=  %>中的代码直接生成到_jspService函数内,所以可以用jsp隐含对象
      

  8.   

    ----
    我用了这种方法
    <%!
    String hello(){
        return "您好,朋友,欢迎进入JSP世界,^_^";
    }
    %>--------
    这种好像不行
    方法改一下,传个out进去
    String func_aa(JspWriter out,String abc)
    {
    out.print("select");
    return("a");
    }调用时
    <%
    String aa=func_aa(out,"welshem");
    %>
    ----