2

我有一个jsp,其中有一些用于重定向到其他html页面或jsps的锚标记。但是一个特定的jsp,我想发送一个参数,即..用户名到jsp ..来自这个jsp ..我该怎么做以一种简单的方式..或任何可能的方式,我想在单击时将从 scriptlet 获得的 uname 参数发送到 jsp SavingAccount.jsp

div class="bar">
 <div class="menulink"><a href="index.html">Home</a></div>
            <div class="menulink"><a href="savingsAccount.jsp">Savings</a></div>
            <div class="menulink"><a href="#">FAQ</a></div>
            <div class="menulink"><a href="#">Help</a></div>
            </div>

    <% 

    Class.forName("com.mysql.jdbc.Driver");
    Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/mutualfund", "root", "");


    Statement statement = connection.createStatement();
    String uname = request.getParameter("uname");
    out.println(uname);
    out.println("Editing "+uname);
    String query="SELECT * FROM `cust_info_table` WHERE `cust_id`=\""+uname +"\"";
    ResultSet resultset =  statement.executeQuery(query) ;
4

2 回答 2

1
div class="bar">
 <div class="menulink"><a href="index.html">Home</a></div>
            <div class="menulink"><a href="savingsAccount.jsp?username=<%=request.getParameter("uname")%>">Savings</a></div>
            <div class="menulink"><a href="#">FAQ</a></div>
            <div class="menulink"><a href="#">Help</a></div>
 </div>
</div>

savingsAccount.jsp您可以使用以下方法获取此参数:

String uname = request.getParameter("username");
于 2013-06-14T11:31:51.067 回答
0

在jsp页面中

<a href="viewProfile?email=<%=request.getParameter("email")%> " >View Profile</a>

在 Java 页面中

   @RequestMapping("/viewProfile")
    public void viewUser(HttpServletRequest req, HttpServletResponse res){

        String email = req.getParameter("email");
        System.out.println(email);
    }
于 2020-05-10T18:30:06.420 回答