62,614
社区成员
发帖
与我相关
我的任务
分享
<%@ page language="java" import="java.util.*,com.denny.user.vo.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
//action 响应内容
//out.println("注册成功!恭喜!");
request.setCharacterEncoding("GBK");
String action = request.getParameter("action");
out.println(action);
if(action != null && action.trim().equals("userregister.jsp")){
out.println(action);
String username = request.getParameter("username");
String password = request.getParameter("userpassword");
UserVo u = new UserVo();
u.setUsername(username);
u.setUserpassword(password);
u.save();
out.println("注册成功!恭喜!");
%>
<center> Register OK</center>
<%
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'userregister.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">
-->
<script language="javascript" type="text/javascript" src="admin/script/regcheckdata.js">
</script>
</head>
<body>
<form name="form" action="userregister.jsp" method="post" onsubmit="return checkdata()">
<table align = "center" border="1" style="border-collapse: collapse;">
<tr>
<th colspan="2">用户注册</th>
</tr>
<tr>
<td>用户名:</td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="userpassword" /></td>
</tr>
<tr>
<th class="tdstyle" colspan="2">
<input type="submit" value="注册" />
</th>
</tr>
</table>
</form>
</body>
</html>
<form name="form" action="userregister.jsp" method="post" onsubmit="return checkdata()">
String action = request.getParameter("action");
out.println(action);
我打印显示结果为空 不知道为什么[/quote]
request.getParameter("action");是获取你提交的那个form里面name为action的文本框或者其他控件的值,但是你提交的那个form中没有,所以结果为空。 <form name="form" action="userregister.jsp" method="post" onsubmit="return checkdata()">
String action = request.getParameter("action");
out.println(action);
我打印显示结果为空 不知道为什么