你的jsp怎么写的,里面有东西编译不成功。

解决方案 »

  1.   

    我的JSP:
    <%@ page import="Converter,java.math.*" %>
    <%@ page contentType="text/html; charset=ISO-8859-1" %>
    <html>
    <head>
        <title><Converter<title>
    </head><body bgcolor="white">
    <h1><center>Converter</center></h1>
    <hr>
    <p>Enter an amount to convert:</p>
    <form method="get">
    <input type="text" name="amount" size="25">
    <br>
    <p>
    <input type="submit" value="Submit">
    <input type="reset" value="Reset">
    </form>
    <%
        String amount=request.getParameter("amount");
        if(amount!=null&&amount.length()>0){
        BigDecimal d=new BigDecimal(amount);
    %><p><%= amount %>dollars are
       <%= Converter.dollarToYen(d) %> Yen.
    <p><%= amount %>Yen are
       <%= Converter.yenToEuro(d) %> Euro.
    <%
        }
    %>
    </body>
    </html>
      

  2.   

    build.xml:<!-- Setting up the Getting Started example to prepare to build and deploy -->
    <project name="wspack-getting-started-example" default=""
     basedir=".">
        <target name="init">
            <tstamp/>
        </target><!-- This section sets properties used in the rest of this build file -->
    <property name="build" value="build"/>
    <property environment="myenv"/><!-- These libraries need to be included in the CLASSPATH -->
    <path id="classpath">
    <fileset dir="${myenv.JWSDP_HOME}/common/lib">
    <include name="*.jar"/>
    </fileset>
    </path>
    <!-- This section prepares the directory structure needed for Web applications -->
    <target name="prepare" depends="init" description="Create build directories.">
        <mkdir dir="${build}/WEB-INF/classes"/>
    </target><!-- This section compiles the java files and copies the HTML and JSP pages to the appropriate locations -->
    <target name="build" depends="prepare"
     description="Compile app java files and copy HTML and JSP pages.">
    <javac srcdir="." destdir="${build}/WEB-INF/classes">
        <include name="**/*.java" />
        <classpath refid="classpath"/>
    </javac>
    <copy todir="${build}">
        <fileset dir=".">
            <include name="*.html"/>
            <include name="*.jsp"/>
        </fileset>
    </copy>
    </target><!-- This section deploys the application by copying the appropriate files to the webapps/directory -->
    <target name="deploy" depends="build"
     description="Deploy app to webapps.">
        <copy todir="${myenv.JWSDP_HOME}/webapps/gs">
            <fileset dir="${build}"/>
        </copy>
    </target></project>
      

  3.   

    将相关的JAR包导入IDE的CLASSPATH
      

  4.   

    这个不是IDE啊,我用的是命令行的ant build和ant deploy
      

  5.   

    import了不能被识别的Converter类,看看是否缺少jar包,或是jar包冲突
      

  6.   

    就是$JWSDP_HOME/common/lib下的吗?本来下载了的这个版本是没有这个common目录的,虽然我自己加了common/lib目录,但是里面没有放任何jar文件也可以build successful。但是启动了tomcat访问这个localhost:8080/gs URL时就出问题了。
      

  7.   

    <%@ page import="Converter,java.math.*" %>应该是:<%@ page import="Converter.java.math.*" %>
      

  8.   

    <%@ page import="Converter,java.math.*" %>???
    没有包结构的类,不能直接import
      

  9.   

    推荐的做法当然是在Converter这个类里加上package的定义咯
    不推荐的做法请参考:
    http://blog.csdn.net/zcjl/archive/2004/10/23/148519.aspx
      

  10.   

    <%@ page import="Converter,java.math.*" %>
    Converter不能识别没有包的类,你给Converter加个包就行了