Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Spring
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Spring
@RequestParam annotation usage for a get request
Deepaks Deshpande
Ranch Hand
Posts: 114
I like...
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Dear all,
I am trying to append the username as a query
string
onto my URL. I am using the following code
@RequestMapping(value="/examlogin.htm?user=", method=RequestMethod.GET, params={"user"}) public String displayExamLogin(HttpServletRequest request, Model model, @RequestParam(value = "user", required = true) String user) throws Exception { // TODO Auto-generated method stub String today = new Date().toString(); String username = request.getAttribute("user").toString(); user = request.getParameter(username); model.addAttribute("user", user); logger.info("Loading the login page... "+today+" POST method"); return "/examlogin.htm?user="; }
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:
18:06:08,265 INFO RequestMappingHandlerMapping:179 - Mapped "{[/examlogin.htm?user=],methods=[GET],params=[user],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String org.iitb.exam.main.controllers.ExamLoginController.displayExamLogin(javax.servlet.http.HttpServletRequest,org.springframework.ui.Model,java.lang.String) throws java.lang.Exception 18:06:25,382 WARN PageNotFound:1108 - No mapping found for HTTP request with URI [/OnlineExam/examlogin.htm] in DispatcherServlet with name 'SpringDispatcher'
Please let me know what i am missing.
Thank you.
Regards,
Deepak
sutha kavi
Greenhorn
Posts: 15
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
I like...
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Dear sutha,
I tried using your code. Now the browser displays a message saying
HTTP Status 400 - Required String parameter 'user' is not present type Status report message Required String parameter 'user' is not present description The request sent by the client was syntactically incorrect.
Regards,
Deepak
Deepaks Deshpande
Ranch Hand
Posts: 114
I like...
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Also when i added the attribute
params={"user"}
to the @RequestMapping annotation, my browser displays the following error message
HTTP Status 400 - type Status report message description The request sent by the client was syntactically incorrect. Apache Tomcat/7.0.40
Please help me.
Regards,
Deepak
sutha kavi
Greenhorn
Posts: 15
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
no WebApplicationContext found: no ContextLoaderListener registered?
RequestMappingHandlerMapping - Did not find handler method
Use of redirect: in Spring MVC
Unable to run sample project
noHandlerFound No mapping found for HTTP request with URI [..]
More...