你这样是不是想输出class Redhat a的值啊。
这样是不行的,因为你的a 是int ,你想类型转换不是这样的。
只能是out.print(String.valueOf(myredhat.a));
又或者你直接把这个东西输出就可以了,不用什么类型转换了
out.print(myredhat.a);

解决方案 »

  1.   

    还是没反应:)
    -------------------
    <%@page language="JAVA" %>
    <html>
    <head><title>JSP02</title></head>
    <body>
    <%
    class Redhat{
    int a;
    a=10;
    }
    Redhat myredhat=new Redhat();
    out.print(myredhat.a);
    %>
    </body>
    </html>
    ------------------------------
    错误提示:
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    ..\work\localhost\_\_0002ftest_0002fm_00030_00033_0002ejspm03_jsp_0.java:58: Identifier expected.
                     a=10;
                      ^
    ..\work\localhost\_\_0002ftest_0002fm_00030_00033_0002ejspm03_jsp_0.java:60: 'try' without 'catch' or 'finally'.
                    Redhat myredhat=new Redhat();
                    ^
    ..\work\localhost\_\_0002ftest_0002fm_00030_00033_0002ejspm03_jsp_0.java:68: Type expected.
            } catch (Throwable t) {
              ^
    3 errors, 1 warning