问题
i want to save the user login info to some variable and send that over HTTP post request to some other login page(New login page is in Grails/Groovy) and paste those saved user information to that page.Hope i made this clear , here is the code i wrote in jsp. Any suggestions will be helpful
<html>
<head>
<title>Enter your name and password</title>
</head>
<body>
<form method="POST" action="loginaction.jsp">
<p><font color="#800000" size="5">First Name:</font><input type="text" name="fname" size="20"></p>
<p><font color="#800000" size="5">Last Name:</font><input type="text" name="lname" size="20"></p>
<p><font color="#800000" size="5">City:</font><input type="text" name="city" size="20"></p>
<p><font color="#800000" size="5">policy Number:</font><input type="text" name="pnum" size="20"></p>
<p><input type="submit" value="Submit" name="B1"></p>
</form>
</body>
</html>
loginaction.jsp
<html>
<body>
<p><%=request.getParameter("fnamename")
request.getParameter("lname")
request.getParameter("city")
request.getParameter("pnum")%></p>
</body>
</html>
回答1:
In Grails you submit the data to a controller. The request will be processed by the action specified in the form's action attribute. Like:
<form method="POST" action="login">
You can get the values of the inputs from this page inside the controller action via params, which is a map with the id of the attribute as a key and its value as, well, value. Like:
def fname = params.fname
And finally, you can render another view passing these params you just received. Like:
render(view:'page', model:[parameters:params])
There are many ways you can use render though. Maybe you can find a better one for your use.
来源:https://stackoverflow.com/questions/12418183/i-wish-to-save-value-entered-by-user-in-textbox-and-send-it-using-http-post-to-s