代码如下:<%@ page language="java" contentType="text/html; charset=gbk"
pageEncoding="gbk"%><!--
String action = request.getParameter("action");
String username = request.getParameter("username");
String password = request.getParameter("password");
if(username == null || !username.equals("user")) {
out.println("username not correct!");
return;
}
if(password == null || password.equals("password")) {
out.println("password not correct!");
return;
}out.println("Welcome!");
--><!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><div align="center">
<div>
<h1>学生选课管理系统</h1>
</div>
<div>
<h2>用户登录/Login</h2>
</div>
<div>
<form name="login" action="LoginDeal.jsp" method="post" onSubmit="Check()">
<label for="">Username:</label> <input type="text" name="username" size="15" value="" /><br />
<br />
<label for="">Password:</label> <input type="password" name="password" size="15" value="" /><br />
<table>
<tr>
<td><input id="RadioButtonList1_0" type="radio" name="RadioButtonList1" value="Manage" tabindex="4" /><label for="RadioButtonList1_0">部门</label></td><td><input id="RadioButtonList1_1" type="radio" name="RadioButtonList1" value="Teacher" tabindex="4" /><label for="RadioButtonList1_1">教师</label></td><td><input id="RadioButtonList1_2" type="radio" name="RadioButtonList1" value="Student" checked="checked" tabindex="4" /><label for="RadioButtonList1_2">学生</label></td>
</tr>
</table>
<input type="submit" name="submit" value="登录" />
<input type="reset" name="reset" value="重置" />
<script language="JavaScript" type="text/javascript">
function Check() {
if(document.login.username.value == "") {
window.alert("账号不能为空!");
return false;
}
if(document.login.password.value == "") {
window.alert("密码不能为空!");
return false;
}
return true;
}
</script>
</form>
<br>
<div>
</div>
</div></div>
</body>
</html>
pageEncoding="gbk"%><!--
String action = request.getParameter("action");
String username = request.getParameter("username");
String password = request.getParameter("password");
if(username == null || !username.equals("user")) {
out.println("username not correct!");
return;
}
if(password == null || password.equals("password")) {
out.println("password not correct!");
return;
}out.println("Welcome!");
--><!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><div align="center">
<div>
<h1>学生选课管理系统</h1>
</div>
<div>
<h2>用户登录/Login</h2>
</div>
<div>
<form name="login" action="LoginDeal.jsp" method="post" onSubmit="Check()">
<label for="">Username:</label> <input type="text" name="username" size="15" value="" /><br />
<br />
<label for="">Password:</label> <input type="password" name="password" size="15" value="" /><br />
<table>
<tr>
<td><input id="RadioButtonList1_0" type="radio" name="RadioButtonList1" value="Manage" tabindex="4" /><label for="RadioButtonList1_0">部门</label></td><td><input id="RadioButtonList1_1" type="radio" name="RadioButtonList1" value="Teacher" tabindex="4" /><label for="RadioButtonList1_1">教师</label></td><td><input id="RadioButtonList1_2" type="radio" name="RadioButtonList1" value="Student" checked="checked" tabindex="4" /><label for="RadioButtonList1_2">学生</label></td>
</tr>
</table>
<input type="submit" name="submit" value="登录" />
<input type="reset" name="reset" value="重置" />
<script language="JavaScript" type="text/javascript">
function Check() {
if(document.login.username.value == "") {
window.alert("账号不能为空!");
return false;
}
if(document.login.password.value == "") {
window.alert("密码不能为空!");
return false;
}
return true;
}
</script>
</form>
<br>
<div>
</div>
</div></div>
</body>
</html>
解决方案 »
- 简单页面跳转,第二次会多一个admin路径
- jsp如何访问绝对路径资源
- 关于处理重复提交的问题
- get传递参数window.open('tuijian.asp?qinqiu='+pp+'&qhang='+bhang,'','') request("qinqiu")值是变量PP+qhang,request("qhang")值空
- 关于Quartz的版权问题
- 帮忙看看这个异常
- 一个通讯簿导出的问题
- public abstract interface Servlet 中的abstract有何意义
- 关于MS Sqlserver分页的问题
- 在tomcat+jdk 下进行SERVLET编程的菜鸟问题
- - =求了个助。。
- javascript中的innerHTML方法加载htc控件
onSubmit="return Check()"
这样的话 onSubmit="return Check()" 整条语句都报错,下面是一条红线
求解
function Check() {
if(document.login.username.value == "") {
window.alert("账号不能为空!");
return false;
}
if(document.login.password.value == "") {
window.alert("密码不能为空!");
return false;
}
[color=#FF0000return true;[/color]
}
</script>
顺序执行后,最后执行return true;了,你说跳转不?
<label for="">Username:</label> <input type="text" name="username" size="15" value="" /><br />
<br />
<label for="">Password:</label> <input type="password" name="password" size="15" value="" /><br />
<table>
<tr>
<td><input id="RadioButtonList1_0" type="radio" name="RadioButtonList1" value="Manage" tabindex="4" /><label for="RadioButtonList1_0">部门</label></td><td><input id="RadioButtonList1_1" type="radio" name="RadioButtonList1" value="Teacher" tabindex="4" /><label for="RadioButtonList1_1">教师</label></td><td><input id="RadioButtonList1_2" type="radio" name="RadioButtonList1" value="Student" checked="checked" tabindex="4" /><label for="RadioButtonList1_2">学生</label></td>
</tr>
</table>
<input type="button" name="button" value="登录" onClick="Check();"/>
<input type="reset" name="reset" value="重置" /><script language="JavaScript" type="text/javascript">
function Check() {
if(document.login.username.value == "") {
window.alert("账号不能为空!");
return false;
}
if(document.login.password.value == "") {
window.alert("密码不能为空!");
return false;
}
onSubmit();
}function onSubmit(){
document.login.action="LoginDeal.jsp";
document.login.submit();
}
</script>
</form>
LZ试试这样行不行
不要以为jsp页面里,onSubmit="return Check();"这个下面会出现红线就以为是错的!
果真是eclipse的问题,两种方法都试过了,都很ok,非常谢谢你!还有楼上的各位,谢谢了!