我的网络应用程序有这个JSP代码:
我在success子句中的"<a href="welcome.html">Delete</a>"
处收到语法错误。任何人都可以帮我确定问题吗?谢谢,谢谢!
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>atozknowledge.com demo loginjsp</title>
</head>
<body>
<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*"%>
<%
String userid=request.getParameter("usr");
session.putValue("userid",userid);
String pwd=request.getParameter("pwd");
Class.forName("com.mysql.jdbc.Driver");
java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/tomcat","root","root");
Statement st= con.createStatement();
ResultSet rs=st.executeQuery("select * from users where userid='"+userid+"'");
if(rs.next())
{
if(rs.getString(2).equals(pwd))
{
out.println("welcome"+userid);
<a href="welcome.html">Delete</a>
}
else
{
out.println("Invalid password try again");
}
}
else
%>
<a href="index.html">Home</a>
</body>
</html>
答案 0 :(得分:1)
<a href="welcome.html">Delete</a>
不是有效的Java代码。如果您想要退出Java scriptlet,请使用%>
执行此操作(然后<%
返回):
%><a href="welcome.html">Delete</a><%
答案 1 :(得分:0)
您的标记插入Java代码部分。 Juste移动你的标签或关闭你的scriptlet
if(rs.getString(2).equals(pwd))
{
out.println("welcome"+userid);
%>
<a href="welcome.html">Delete</a>
<%
}
else
{
out.println("Invalid password try again");
}