Reputation: 679
I have the following code:
<c:forEach var="listValue" items="${upcomingMovieslists}">
div style="border:thin inset #6E6E6E; text-align: justify;> <p margin-left: 1em;"> <c:set var="movieName" scope="application" value="${listValue.key}"/><a href="/myapp/movie/SubmitMovie/" >${listValue.key}</a></p></div>
</c:forEach>
and movieName is going to be in @RequestParam String movieName in the page that it is going next.
So, When I run this code I am getting an error telling:
error:
message Required String parameter 'movieName' is not present
description The request sent by the client was syntactically incorrect.
Controller method:
My controller class to where the call is going:
@RequestMapping(value="/SubmitMovie", method = RequestMethod.GET)
public ModelAndView getSearchedMovie(@RequestParam String movieName, ModelMap model)
The URL currently is: /myapp/movie/SubmitMovie/
It should be /myapp/movie/SubmitMovie/?movieName=deadpool
in order to work
I should have /?movieName= to show the results in the next page but where as with the above jsp code I will not get the movieName in String format instead it comes in the form ${movieName} which cannot be accepted to a String present in the RequestParam and hence it throws an error.
I want to know how I can fix it to get the moviename in Stringformat in the URL so that I can populate the results
Thanks
Upvotes: 0
Views: 595
Reputation: 88
There's not a whole lot of code there, so I don't know exactly what you're going for, but you can always add a required=false
condition to a request parameter, like so:
@RequestParam(value = "movieName", required = false) String movieName
That should at least clear that error. If the logic in your model does require movieName, though, then you're going to need to refactor around that -- i.e., your link would need to look like href="/myapp/movie/SubmitMovie?movieName='${listValue.key}'"
.
(Note: I'm inferring from your code that ${listValue.key}
is the name of the movie. Whatever variable you want the controller to receive as the @RequestParam String movieName
, place it after ?movieName=
in the href string, after escaping it with single quotes (see how I did so above.)
If you're still stuck, maybe try showing the controller for the page with that parameter?
Upvotes: 1