在Sqrt.jsp中实现如下功能:输入一三角形三个边的边长,判断是否符合构成三角形的条件.如果符合,则计算三角形的面积.
代码如下:Sqrt.jsp<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd"><html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Sqrt</title>
    </head>
    <body><center>
        请输入三角形三个边长<p>
    <form action="" method="post">
        第一边长:
        <input type="text" name="first"><br>
        第二边长:
        <input type="text" name="second"><br>
        第三边长:
        <input type="text" name="third"><br><p>
        <input type="submit" name="submit" value="确定">
        <input type="reset" name="reset" value="取消"><p>
    </form>
    
<%!
   String First;
   String Second;
   String Third;
%><%
   First=request.getParameter("first");
   Second=request.getParameter("second");
   Third=request.getParameter("third");
   
   double first=Double.valueOf(First).doubleValue();
   double second=Double.valueOf(Second).doubleValue();
   double third=Double.valueOf(Third).doubleValue();
   
   if(first+second>third && first+third>second && third+second>first){
       double p=(first+second+third)/2;
       double result=Math.sqrt(p*(p-first)*(p-second)*(p-third))
       out.print(result);
   }else{
       
       out.print("不能构成三角形");
   }
%>   </body>
</html>
可是我运行了很多遍,都提示说出错.提示出错如下:D:\Java\WebApplication1\build\generated\src\org\apache\jsp\Sqrt_jsp.java:89: 警告: 编码 GBK 的不可映射字符
       out.print("涓嶈兘鏋勬垚涓夎褰?");
                            ^
D:\Java\WebApplication1\build\generated\src\org\apache\jsp\Sqrt_jsp.java:86: 需要 ';'
       out.print(result);请大家给看看,这是怎么回事?给解决一下,谢谢了!    

解决方案 »

  1.   

    double result=Math.sqrt(p*(p-first)*(p-second)*(p-third)) 这行少了个 ";"  //分号
      

  2.   

    double result=Math.sqrt(p*(p-first)*(p-second)*(p-third)) 语法错误
      

  3.   

    你用开发工具打开文件时,选择打开编码为utf-8看看.如果是乱码,从新输入一便中文部分保存就好了,我以前遇到过。
      

  4.   

    服务器运行得环境编码不对, 试一试指定编码 java -Dfile.encoding=GBK ...