源代码如下:<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.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 type="text/javascript">
function checkForm()
{
if(form1.userId.value == "")
{
alert("用户名不能为空");
form1.userId.focus();
return false;
}
if(form1.pwd.value == "")
{
alert("密码不能为空");
form1.userId.focus();
return false;
}
for(var i=0;i <3;i++)
{
if(i==2){alert("密码不能为空");return false;}
if(document.all.shengfen[i].checked){
reutrn true;
}
}
if(form1.userId.value.length<6||form1.userId.value.length>12)
{
alert("用户名输入长度错误,长度应介于6与12位之间");
form1.userId.focus();
return false;
}
if(form1.pwd.value.length<6||form1.pwd.value.length>12)
{
alert("密码输入长度错误,长度应介于6与12位之间");
form1.pwd.focus();
return false;
}
}
</script>
</head>
<body bgcolor="gray">
<h1 align="center"> 欢迎来到武科大教务管理系统</h1>
<hr>
<table width="99%" border="0">
<tr>
<td height="71" colspan="3"><h1 align="center">welcome</h1></td>
</tr>
<tr>
<td height="203"> </td>
<td width="42%">
<form action="./Login" method="post" name="form1">
<input type=hidden name="commitFlag" value="submit">
<table width="100%" border="0">
<tr>
<td width="66%" height="56" align="right"><span>用户名:</span></td>
<td width="54%"><input name="userId" type="text" class="text1" size="10" maxlength="16"></td>
</tr>
<tr>
<td height="47" align="right"><span >密码: </span></td>
<td><input name="pwd" type="password" class="text1" size="10" maxlength="16"></td>
</tr>
<tr>
<td width="46%" height="56" align="right"><span >身份:</span></td>
<td width="54%">
<input type="radio" name="shengfen" value="teacher" />教师<br>
<input type="radio" name="shengfen" value="student" />学生<br>
<input type="radio" name="shengfen" value="db" />管理员<br>
</td>
</tr>
<tr>
<td height="40" align="right"> </td>
<td align="left">
<input name="submintButton" type="submit" class="button1" value="确定" onclick="return checkForm()" >
<input name="reset" type="reset" class="button1" id="reset" value="取消">
</td>
</tr>
</table>
</form>
</td>
<td width="45%"> </td>
</tr>
<tr>
<td height="235"> </td>
<td> </td>
<td> </td>
</tr>
</table> </body>
</html>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.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 type="text/javascript">
function checkForm()
{
if(form1.userId.value == "")
{
alert("用户名不能为空");
form1.userId.focus();
return false;
}
if(form1.pwd.value == "")
{
alert("密码不能为空");
form1.userId.focus();
return false;
}
for(var i=0;i <3;i++)
{
if(i==2){alert("密码不能为空");return false;}
if(document.all.shengfen[i].checked){
reutrn true;
}
}
if(form1.userId.value.length<6||form1.userId.value.length>12)
{
alert("用户名输入长度错误,长度应介于6与12位之间");
form1.userId.focus();
return false;
}
if(form1.pwd.value.length<6||form1.pwd.value.length>12)
{
alert("密码输入长度错误,长度应介于6与12位之间");
form1.pwd.focus();
return false;
}
}
</script>
</head>
<body bgcolor="gray">
<h1 align="center"> 欢迎来到武科大教务管理系统</h1>
<hr>
<table width="99%" border="0">
<tr>
<td height="71" colspan="3"><h1 align="center">welcome</h1></td>
</tr>
<tr>
<td height="203"> </td>
<td width="42%">
<form action="./Login" method="post" name="form1">
<input type=hidden name="commitFlag" value="submit">
<table width="100%" border="0">
<tr>
<td width="66%" height="56" align="right"><span>用户名:</span></td>
<td width="54%"><input name="userId" type="text" class="text1" size="10" maxlength="16"></td>
</tr>
<tr>
<td height="47" align="right"><span >密码: </span></td>
<td><input name="pwd" type="password" class="text1" size="10" maxlength="16"></td>
</tr>
<tr>
<td width="46%" height="56" align="right"><span >身份:</span></td>
<td width="54%">
<input type="radio" name="shengfen" value="teacher" />教师<br>
<input type="radio" name="shengfen" value="student" />学生<br>
<input type="radio" name="shengfen" value="db" />管理员<br>
</td>
</tr>
<tr>
<td height="40" align="right"> </td>
<td align="left">
<input name="submintButton" type="submit" class="button1" value="确定" onclick="return checkForm()" >
<input name="reset" type="reset" class="button1" id="reset" value="取消">
</td>
</tr>
</table>
</form>
</td>
<td width="45%"> </td>
</tr>
<tr>
<td height="235"> </td>
<td> </td>
<td> </td>
</tr>
</table> </body>
</html>
解决方案 »
- 8080端口问题
- java类通过jdbc连接mysql数据库显示建立连接失败
- Mysql如何返回批量插入后的ID?
- web 开发 客服端的数据处理用怎样的客服端脚本语言最好? 这个问题绝对值得回答.
- 关于hibernate使用的一个小问题
- 可能是老题目,模型是购物车模式的,怎么去掉重复选择的物品??
- web.xml的error-page页面一般错误显示正常,但通过过滤器跳转的错误页面出现乱码
- 新手提问:关于数据库连接问题
- 急求SSM开发框架
- myeclipse运行程序,浏览器出现的地址localhost位置是一些乱东西!
- oracle的数据备份与恢复..急求答案,各位多多发言,谢谢
- javaws如何选择jre版本?
action="<%=basePath%>./Login"
action="<%=basePath%>Login"慢慢试试!!
改成<form action="<%=path%>/servlet/Login.do" method="post" name="form1">
前提是你的xml文件没改过 是自动生成的。
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
不需要的话就手动删除了吧
可能是web.xml中的<url-pattern>配置错了,跟表单的action=""不相符
if(document.form1.userId.value == "")
{
alert("用户名不能为空");
form1.userId.focus();
return false;
}
你少了个document
至于你的跳转页面错误应该是你的action写得不对,你要跳转到那个servlet就应该是web.xml里面的那个servlet的url.
第一,你这个页面必须直接在项目的WebContent文件夹下。
第二,你login必须在xml中进行注册和配置路径。