在jsp中,如何由字符串转化成Int型????

来源:百度知道 编辑:UC知道 时间:2024/05/30 17:48:48
多谢!我主要想做两个网页,一个是输入数字的,另一个输出答案!我的代码如下,请教一下该如何改。
//第一个:
lian1.jsp:
<%@ page contentType="text/html;charset=gbk";%>
<html>
<head>
<title>加法</title>
</head>
<body>

<form action="lian2.jsp">
加数:<input type="text"name="jiashu1"><br>
加数:<input type="text"name="jiashu2"><br>
<input type="submit"name="submit"value="等于">
</form>
</body>
</html>
lian2.jsp:
<%@ page contentType="text/html;charset=gb2312"%>
<html>
<head>
<title>
和的值
</title>
</head>
<body>
<%int a = (Integer)request.getParameter(&q

//改好了,可以运行了……

lian1.jsp:
<%@ page contentType="text/html;charset=gbk";%>
<html>
<head>
<title>加法</title>
</head>
<body>

<form action="lian2.jsp">
加数:<input type="text"name="jiashu1"><br>
加数:<input type="text"name="jiashu2"><br>
<input type="submit"name="submit"value="等于">
</form>
</body>
</html>

lian2.jsp:

<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<html>
<head>
<title>
和的值
</title>
</head>
<body>
<%
int a = Integer.parseInt(request.getParameter("jia