2013-04-22 79 views
-2

此代码在编译时不包含错误,但在运行时会出现错误。 我无法在tomcat 7.0上运行此代码。我开始重新启动它几次。你能告诉我任何想法如何改变代码,使其工作?此代码在编译时不包含错误,但在运行时会出现错误。

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> 
<!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=ISO-8859-1"> 
    <title>Insert title here</title> 
    </head> 
    <%@ page import="java.util.*" %> 
    <body> 
     <form action="MyWSserve" method="get">Enter Zip Code 
     <br> 
     <input type="text" name="zipcode"></input> 
     <input type="submit" name="GO" value="GO"></input> 
     </form> 
     <% //Object obj=request.getAttribute("values"); 
     //if(obj instanceof ArrayList){ 
     //ArrayList<String>mylist = (ArrayList<String>)obj; }%> 
     <% //Iterator<String>itr = mylist.iterator(); %> 
     <% String[] strcode=(String[])request.getAttribute("values"); %> 
     <p>The Temperature in Centigrade <%=strcode[0] %><br></p> 
     <p>The Temperature in Farenheit <%=s trcode[1] %><br></p> 
     <p>The Pressure is <%=s trcode[2] %><br></p> 
     <p>The weather Condition is <%=s trcode[3] %><br></p> 
    </body> 
</html> 
+0

你得到什么错误? – 2013-04-22 18:28:17

回答

0

试试这个:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> 
<!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=ISO-8859-1"> 
    <title>Insert title here</title> 
    </head> 
    <%@ page import="java.util.*" %> 
    <body> 
     <form action="MyWSserve" method="get">Enter Zip Code 
     <br> 
     <input type="text" name="zipcode"></input> 
     <input type="submit" name="GO" value="GO"></input> 
     </form> 
     <% //Object obj=request.getAttribute("values"); 
     //if(obj instanceof ArrayList){ 
     //ArrayList<String>mylist = (ArrayList<String>)obj; }%> 
     <% //Iterator<String>itr = mylist.iterator(); %> 
     <% String[] strcode = request.getParameterValues("values"); %> 
     <% if (strcode != null && strcode.length >= 4) { %> 
     <p>The Temperature in Centigrade <%=strcode[0] %><br></p> 
     <p>The Temperature in Farenheit <%= strcode[1] %><br></p> 
     <p>The Pressure is <%= strcode[2] %><br></p> 
     <p>The weather Condition is <%= strcode[3] %><br></p> 
     <% } else { %> 
     <p>Call this page using 4 parameters called "values": 
     <a href="?values=1st&values=2nd&values=3rd&values=4th">?values=1st&values=2nd&values=3rd&values=4th</a> 
     <% } %> 
    </body> 
</html> 
相关问题