日期:2014-05-17  浏览次数:20717 次

为什么强转出现500错误
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
  </head>
  
  <body>
    <form action="index.jsp" method="post">
    <input type="text" name="num1">
    <select name="opt">
    <option value="+">+</option>
    <option value="-">-</option>
    <option value="*">*</option>
    <option value="/">/</option>
    </select>
     <input type="text" name="num2">
    <input type="submit" value="提交"/>
    </form>
    <%
   
    String str1=request.getParameter("num1");
    String str2=request.getParameter("num2");
    String str3=request.getParameter("opt");
    int a=Integer.parseInt(str1);
    int b=Integer.parseInt(str2);
    if(str3.equals("+")){
    out.print(a+str3+b+"="+(a+b));
    }
    if(str3.equals("-")){
    out.print(a+str3+b+"="+(a-b));
    }
   if(str3.equals("*")){
    out.print(a+str3+b+"="+(a*b));
    }
    if(str3.equals("/")){
    out.print(a+str3+b+"="+(a/b));
    }
     %>
  </body>
</html>

















为什么强转出现500错误
jsp

------解决方案--------------------
第一,
int a=Integer.p