aspose file tools*
The moose likes Spring and the fly likes @RequestParam annotation usage for a get request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "@RequestParam annotation usage for a get request" Watch "@RequestParam annotation usage for a get request" New topic
Author

@RequestParam annotation usage for a get request

Deepaks Deshpande
Ranch Hand

Joined: Dec 06, 2007
Posts: 113

Dear all,

I am trying to append the username as a query string onto my URL. I am using the following code


and i am calling the link in my menu page as follows:
<a href="examlogin.htm?user=">Login to take the exam</a>

Now, whenever i click the link, i get a 404 error and my logger shows the following on the console:

Please let me know what i am missing.
Thank you.


Regards,
Deepak

sutha kavi
Greenhorn

Joined: Jun 10, 2011
Posts: 14
Hi,

The following code is enough while using @RequestParam,

@RequestMapping(value="/examlogin.htm", method=RequestMethod.GET)
public String displayExamLogin(HttpServletRequest request, Model model, @RequestParam(value = "user", required = true) String user) throws Exception{
String today = new Date().toString();

model.addAttribute("user", user);
logger.info("Loading the login page... "+today+" POST method");
return "/examlogin.htm?user=";
}

Thanks,
Sutha
Deepaks Deshpande
Ranch Hand

Joined: Dec 06, 2007
Posts: 113

Dear sutha,
I tried using your code. Now the browser displays a message saying
Deepaks Deshpande
Ranch Hand

Joined: Dec 06, 2007
Posts: 113

Also when i added the attribute to the @RequestMapping annotation, my browser displays the following error message


Please help me.
sutha kavi
Greenhorn

Joined: Jun 10, 2011
Posts: 14
Hi,

while using the below code,

@RequestMapping(value="/examlogin.htm", method=RequestMethod.GET)
public String displayExamLogin(HttpServletRequest request, Model model, @RequestParam(value = "user", required = true) String user) throws Exception{
String today = new Date().toString();

model.addAttribute("user", user);
logger.info("Loading the login page... "+today+" POST method");
return "";
}

Can you tell the url that has been used for accessing the above?

Regards,
Sutha
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: @RequestParam annotation usage for a get request