I am having a form which submits new articles to my controller.
JSP Page:
<form class="form-signin" method="post"
action="/articleViewer">
<div class="control-group" style="margin-top: -5px;">
<label class="control-label text-info" for="commentContent"><strong>Post
Comment</strong></label>
<div class="controls">
<textarea class="FormElement" name="area2" id="commentContent"
style="width: 100%;"></textarea>
</div>
</div>
<button type="submit" class="btn btn-primary" style="margin-left: 90%;">Post</button>
</form>
Controller Method:
@RequestMapping(value="/articleViewer", method = RequestMethod.POST)
public String saveArticleComment (HttpServletRequest request, HttpServletResponse response,Principal principal, ModelMap map) throws ServletException, IOException{
//processing request
System.out.println("Link : "+Path.Jsp.ARTICLE_VIEWER_PAGE);
return Path.Jsp.ARTICLE_VIEWER_PAGE; //this ARTICLE_VIEWER_PAGE = /articleViewer
}
Now from the above controller method I wanna redirect to another method where I want to pass
currently saved article id as http://<myurl>/article?articleId="xyz".
Here is my get method code for handling the redirect.
@RequestMapping(value="/articleViewer", method= RequestMethod.GET)
public String articleViewer(HttpServletRequest request, Principal principal,
ModelMap map, HttpServletResponse response)
throws DatabaseException {
//I wanna access article id here.
return Path.Jsp.ARTICLE_VIEWER_PAGE;
}
I wanna know how could I access that passed request parameter in above method?