这是一个简单登陆的程序,先执行login.jsp 输入“abc”后点“确定”,没有转入ok。为什么?谢谢~~
login.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<center>
<form method=get action="test.jsp">
username<input type=text name=username>
<br><br>
<input type=submit value="确定">
</form>
</center>
</body>
</html>
test.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<html>
<body>
<%
string username=request.getparameter("username");
if(username.trim().equals("abc"))
{%>
<jsp:forward page="ok" />
<%}
else
{%>
<jsp:forward page="no" />
<%}
%>
</body>
</html>
ok.htm
<html>ok</html>
no.htm
<html>no</html>
[此贴子已经被作者于2007-11-18 9:52:05编辑过]
----------------解决方案--------------------------------------------------------
string username=request.getparameter("username");
改成
String username=request.getParameter("username");
----------------解决方案--------------------------------------------------------
呵呵 关键字
----------------解决方案--------------------------------------------------------
这里是有问题,不过还是不能正常运行啊
----------------解决方案--------------------------------------------------------
username<input type=text name=username>
改成
username<input type=text name="username">试试
----------------解决方案--------------------------------------------------------
应该是楼上的人说的那样,改改就行了~~
----------------解决方案--------------------------------------------------------
html的属性加不加引号都一样的,好像要在forward里面加个flush="true",试下看,有点忘了
----------------解决方案--------------------------------------------------------
你的程序有问题。
首先 你的login.jsp
<form method=get action="test.jsp"> 以 get提交是不对的
再次你的 text.jsp
string username=request.getparameter("username"); 中有两个错误 string 改String getparameter改 getParameter
text.jsp 需要导包<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
跳HTML 的时候很容易出错的 HTML 你要在站点工程下新键
下面是我改后的代码:
longin
ontentType="text/html; charset=GBK" %>
<html>
<head>
<title>
longin
</title>
</head>
<body bgcolor="#ffffff">
<form method="post" action="text.jsp">
用户:<input type="text" name="username" value="" />
<input type="submit" name="确定" value="Submit">
<input type="reset" value="取消">
</form>
</body>
</html>
text.jsp
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>
text
</title>
</head>
<body bgcolor="#ffffff">
<h1>
text
</h1>
<%
String username=request.getParameter("username");
if(username.trim().equals("abc"))
{%>
<jsp:forward page="ok.jsp" />
<%}
else
{%>
<jsp:forward page="no.jsp" />
<%}
%>
</body>
</html>
我把HTNL改为JSP
ok.jsp
no.jsp
就成功了....
你要是非要html 的话也可以 但是你在用工具的时候 最好用工具新建 不要手动新键
----------------解决方案--------------------------------------------------------
我后来发现我几个有能放在一起。
谢谢各位啦!
----------------解决方案--------------------------------------------------------