• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

@RequestParam annotation usage for a get request

 
Ranch Hand
Posts: 114
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 114
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear sutha,
I tried using your code. Now the browser displays a message saying
 
Deepaks Deshpande
Ranch Hand
Posts: 114
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also when i added the attribute to the @RequestMapping annotation, my browser displays the following error message


Please help me.
 
sutha kavi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
If you live in a cold climate and on the grid, incandescent light can use less energy than LED. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic