-
Oct 10th, 2008, 03:55 AM
#1
Jstl cannot resolve map variable
Please who has solution to this problem.
org.apache.jasper.JasperException: Unable to find a value for "COUNTRYCODE" in object of class "java.lang.String" using operator "."
org.apache.jasper.servlet.JspServletWrapper.handle JspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
org.springframework.web.servlet.view.InternalResou rceView.renderMergedOutputModel(InternalResourceVi ew.java:97)
org.springframework.web.servlet.view.AbstractView. render(AbstractView.java:247)
org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:839)
org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:616)
org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:543)
org.springframework.web.servlet.FrameworkServlet.s erviceWrapper(FrameworkServlet.java:390)
org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:341)
javax.servlet.http.HttpServlet.service(HttpServlet .java:689)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
The block of code that triggered the error is shown below:
<tr class="row2">
<td width="37%" align="right" nowrap><Strong><font face='century gothic' >Country</font></td>
<td width="3%"></td>
<td width="60%">
<spring:bind path="contact.countryCode">
<select name="countryCode" class="select">
<option selected value="">(SELECT)${status.value}</option>
<c:forEach items="${countries}" var="county">
<option value="${county.COUNTRYCODE}" <c:if test="${status.value eq county}">selected</c:if>>${county.COUNTRYNAME}</option>
</c:forEach>
</select>
<font color="red">${status.errorMessage}</font>
</spring:bind>
</td>
</tr>
countries is a list of map objects while county is a reference variable to the map objects in the list.
Last edited by sundec19; Oct 10th, 2008 at 04:06 AM.
Reason: Typo graphical error
-
Oct 11th, 2008, 10:50 AM
#2
are you sure there is filed named "COUNTRYCODE" in county, and there also should be the setter and getter.
-
Oct 13th, 2008, 04:41 AM
#3
Jstl cannot resolve map variable
Below is the refenceData method of the controller.
protected Map referenceData(HttpServletRequest request) throws Exception {
Map model = new HashMap();
model.put("countries", listWriter.getCountries());
return model;
}
Also, below is the block of code that fetches contries data fron database.
Please help!!!
public List<Map> getCountries(){
String query = "select country_code as countryCode, upper(country_description) as countryName from country order by country_description";
return springDao.getResultMap(query);
}
Below is the springDao referenced above:
public List<Map> getResultMap(String query){
log.info(query);
List<Map> lst= new ArrayList<Map>();
try{
lst = (List<Map>)getJdbcTemplate().queryForList(query);
}catch(Exception exp){
log.fatal(exp);
}
return lst;
}
-
Oct 13th, 2008, 10:45 AM
#4
Make sure your servlet container is 2.4+ - as this could be down to you not being able to use the expression language.
Also, drop the spring bind tags if you're using spring 2.0+ and use the form taglibs.
Lastly check your spelling as "county" should be "country"
-
Oct 13th, 2008, 10:53 AM
#5
Jstl cannot resolve map variable
I'm using Tomcat 5.5.17 which is a Servlet 2.4+ compliant container.
Using country as the variable didn't work as well.
I'm using spring 1.2.9. Please if this is not a version of Spring 2.0+, help me with sample code of form taglibs.
-
Oct 13th, 2008, 11:17 AM
#6
do u have
version="2.4" in your web.xml and have you used the expression language in other pages on your site?
Regarding form taglib - u will need to upgrade your spring libs and then read http://static.springframework.org/sp...jsp-formtaglib
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules