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>
<%@ 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>
<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>
没有包结构的类,不能直接import
不推荐的做法请参考:
http://blog.csdn.net/zcjl/archive/2004/10/23/148519.aspx
Converter不能识别没有包的类,你给Converter加个包就行了