This week's book giveaway is in the JDBC and Relational Databases forum.
We're giving away four copies of Murach's MySQL and have Joel Murach on-line!
See this thread for details.
Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

@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
 
Beware the other head of science - it bites! Nibble on this message:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic