Topic: 请教高手 |
Print this page |
1.请教高手 | Copy to clipboard |
Posted by: chuliang Posted on: 2004-10-10 15:02 <%@ page contentType="text/html; charset=GBK" %> <html> <head> <title>汇率转换示例</title> </head> <body> <h3>转换后的结果如下所示:</h3> <% //取得被转换的货币 int currencyFrom=Integer.parseInt(request.getParameter("currencyFrom")); //取得转换的货币 int currencyTo=Integer.parseInt(request.getParameter("currencyTo")); //声明金额变量 double amount=0; String amountStr=""; //声明转换后金额的变量 double amountRes=0; //声明货币字符数组 String[] currencies={"人民币","英镑","美元"}; //声明汇率数组 1:double exchangeRates[][]={{1,0.083,0.125},{12,1,1.5},{8,0.667,1}}; //取得金额字符串 amoutStr=request.getParameter("amount"); try{ //将金额字符串转换为数字 amount=Double.parseDouble(amountStr); //进行货币转换操作 amountRes=amount*exchangeRates[currencyFrom][currencyTo]; //进行四舍五入操作,保留3位小数 amountRes=Math.round(amountRes*1000); amountRes/=1000; out.println("<p>"+amount+currencies[currencyFrom]+"="+amountRes+currencies[currencyTo]+"</p>"); }catch(Exception ex){ //当输入的不是数字时,产生异常 out.println("<p>金额输入框内应该输入数字.</p>"); } %> <p><a href="ExchangeRateDemo1.jsp">重新进行汇率转换操作</a></p> </body> </html> 为什么会出现这样的问题,问题如下所示: Generated servlet error: [javac] Since fork is true, ignoring compiler setting. [javac] Compiling 1 source file [javac] Since fork is true, ignoring compiler setting. [javac] D:\Tomcat4.1\work\Standalone\localhost\myweb\ExchangeRateDemo2_jsp.java:63: not a statement [javac] 1:double exchangeRates[][]={{1,0.083,0.125},{12,1,1.5},{8,0.667,1}}; [javac] ^ [javac] D:\Tomcat4.1\work\Standalone\localhost\myweb\ExchangeRateDemo2_jsp.java:63: ';' expected [javac] 1:double exchangeRates[][]={{1,0.083,0.125},{12,1,1.5},{8,0.667,1}}; [javac] ^ [javac] 2 errors |
2.Re:请教高手 [Re: chuliang] | Copy to clipboard |
Posted by: nothing Posted on: 2004-10-10 15:40 1: 是个啥意思涅? |
3.Re:请教高手 [Re: chuliang] | Copy to clipboard |
Posted by: chuliang Posted on: 2004-10-11 08:18 我是问在TOMCAT中为什么会出现上面所显示的问题. |
4.Re:请教高手 [Re: chuliang] | Copy to clipboard |
Posted by: nothing Posted on: 2004-10-11 08:52 因为你的jsp中出来个 1: jsp文件编译不过去了,tomcat所以就出来提示了呗. |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |