测试jsp

时间:2023-03-08 16:55:26
测试jsp

一. get.jsp

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="com.XX.redisUtil"%> <form action="" method="post"> topicId:<input name="topicId" value="" /> <input type="submit"
value="确定" />
</form> <%
String topicId = request.getParameter("topicId"); if (topicId != null && !topicId.equals("")) {
String key = "AAAA:" + topicId;
out.println("<span style=\"font-size:15px;color: blue\">[<b>"
+ key + "</b>]</span>=");
out.println("<span style=\"font-size:15px;color: red\"><b>"
+ redisUtil.get(key)
+ "</b></span><br />"); }
%>

二. set.jsp

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="com.XXX.redisUtil"%> <form name="form" action="" method="post" onsubmit="return check()"> key:<input name="key" value="" /><input name="value" value="" /> <input
type="submit" value="确定" />
</form> <script>
function check() {
var key=document.form.key.value;
var value = document.form.value.value;
if (confirm("[" + key + "]="+value+"?")) {
return true;
}
return false;
}
</script> <%
String key = request.getParameter("key");
String value = request.getParameter("value"); if (key != null && !key.equals("")) {
String ret = redisUtil.setex(key, 3600, value);
out.println("<span style=\"font-size:15px;color: green\"><b>"
+ ret + "</b></span><br /><br />");
out.println("<span style=\"font-size:15px;color: blue\">[<b>"
+ key + "</b>]</span>=");
out.println("<span style=\"font-size:15px;color: red\"><b>"
+ redisUtil.get(key)
+ "</b></span><br />");
}
%>