使用response.redirect传递数据库值

问题描述 投票:1回答:1
<body>
   <%@page import="java.sql.*" %>
    <%@page import="javax.sql.*" %>
    <%
        String user=request.getParameter("username");
        session.putValue("uname",user);
        String pass=request.getParameter("pass");
        Class.forName("com.mysql.jdbc.Driver");
        java.sql.Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/javaproject","root","");
        Statement st=con.createStatement();
        ResultSet rs=st.executeQuery("select * from university where username='"+user+"'");
        if(rs.next())
        {
            if(rs.getString(3).equals(pass))
            {
                              response.sendRedirect("Uuserprofile.jsp?id=<%=rs.getString("id")%>");

            }

netbeans ide说')'未封闭的字符串文字,但我不明白它的遗失

html jsp servlets response.redirect
1个回答
1
投票

改变这个:

response.sendRedirect("Uuserprofile.jsp?id=<%=rs.getString("id")%>");

对此:

response.sendRedirect("Uuserprofile.jsp?id="<%=rs.getString("id")%>);
© www.soinside.com 2019 - 2024. All rights reserved.