【发布时间】:2014-09-09 15:17:36
【问题描述】:
这是我为验证登录而编写的代码:
<html>
<head>
<meta http-equiv="Content-Type" content="javascript/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<% String username=request.getParameter("username");
String password=request.getParameter("password");
if((username.equals("root") && password.equals("Root@123")))
{
session.setAttribute("username",username);
response.sendRedirect("admin.html");
}
else if((username.equals("school") && password.equals("school@123")))
{
session.setAttribute("username",username);
response.sendRedirect("school.jsp");
}
else
{
response.sendRedirect("Error.jsp");
}
%> </body>
</html>
但不是执行它来显示<% - - - - %> 中的代码。
有人请帮我解决这个问题。
有时会运行,有时不会。
【问题讨论】:
-
我不确定这是什么(可能是 Microsoft 的可憎之处之一),但您没有将它作为 JavaScript 运行。
-
愚蠢的问题...你的分机是
.jsp吗? -
我刚试过,包括我在 之间的代码,它都不是那样工作的,
-
@DavidThomas 那无济于事。他没有使用javascript,而是使用java。使用
<script>不会做任何事情。 -
它是否在服务器环境中运行?