我使用JSP JBeans技术简单地制作了计算器。问题是在jsp文件中单击“提交”按钮后,我不知道如何查看文本区域的先前状态(单击“提交”按钮之前)。我只能在.jsp文件(学校项目)中使用。有什么想法怎么做?非常感谢。
.jsp文件:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Kierski</title>
</head>
<body>
<jsp:useBean id="calculator" class="kierski.Kierski" scope="session"/>
<form action = "kierski.jsp" method="post">
<input type="text" name="expr" value = "">
<jsp:setProperty property="expr" name="calculator"/>
<input type = "submit" value="=">
<jsp:getProperty property = "result" name = "calculator"/>
<br><br>
<font size="5" color="red">
<jsp:getProperty property = "message" name = "calculator"/>
</font>
</form>
</body>
</html>
.java文件(由于发布问题,我从getResult方法中删除了一些内容)
package kierski;
public class Kierski {
String expr;
String result;
String message;
public Kierski(){
super();
expr = "";
result = "";
message = "";
}
public void setExpr(String equation){
this.expr = equation;
System.out.println("ustawiono");
}
public String getExpr(){
return this.expr;
}
public String getResult() {
System.out.println(expr);
String[] numberStr = {"",""};
int whichNumber = 0;
boolean markflag = false;
int whatToDo = 0;
message = "";
return result;
}
public String getMessage() {
return this.message;
}
}