📄 new_post.jsp
字号:
<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%>
<!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=GBK">
<title>发表新帖子</title>
</head>
<body>
<!-- 载入页头 -->
<jsp:include page="./include/top.jsp"></jsp:include>
<%
int tmp = 0;
String vcode = "";
//生成验证码 1001-9999
do {
tmp = (int) (Math.random() * 10000 - 1);
} while (tmp <= 1000);
vcode = String.valueOf(tmp);
%>
<script language="javascript">
function check(){
if(form.title.value==""){
alert("请输入标题!");
return false;
}
if(form.vcode.value!=<%=vcode%>){
alert("验证码不正确!");
return false;
}
}
</script>
<%
String username = "";
String authorid = "";
if (null != session.getAttribute("login")) {
username = session.getAttribute("login").toString();
if (null != session.getAttribute("authorid"))
authorid = session.getAttribute("authorid").toString();
%>
<form name="form" action="new_post_Action.jsp" method="post"
onsubmit="return check()">
标题:
<br>
<br>
<input type="text" maxlength="50" size="80" name="title">
<br>
<br>
作者:
<font color="blue"><%=username%></font>
<input type="hidden" value="<%=authorid%>" name="authorid">
<br>
<br>
<font color="red">内容最大长度1000字符</font>
<br>
<textarea name="content" rows="10" cols="80"></textarea>
<br>
<p>
验证码:
<input type="text" maxlength="4" size="4" name="vcode">
<font color="red"><%=vcode%></font>
</p>
<br>
<input type="submit" name="submit" value="提交">
<input type="reset" name="reset" value="重置">
</form>
<%
} else {
response.sendRedirect("error.jsp");
}
%>
<!-- 载入页尾 -->
<jsp:include page="./include/foot.jsp"></jsp:include>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -