Pivotal Knowledge Base


Can Spring:Eval Work Inside a JSP Page Without a Controller?


 Product   Version
 Spring  All


You may access a bean, bean property, bean method, or system properties using the @Value. For example:


   public class myTestBean{

                  public void setSomeElementList(ElementList thisList) {

Note: systemProperties is a predefined variable and someBean is the name of the bean.

Using the exact Spring Expression Language inside <spring:eval> (which was introduced in Spring version 3.0.1) in a view or JSP,

<spring:eval ="#{someBean.getSomeElementList()}" var="someList"/ >

The same expression language used in myTestBean will not work on JSP inside <spring:eval> without the use of controllers. This article explains how we can make this specific expression language work with the use of controllers. 


<spring:eval> is not to be used in JSP without using a Controller. As of writing this article, to access beans i.e. someBean as described in the above code is only feasible if it is exposed to the view. An example for that is:

public class MyController {
private SomeBean someBean public  ModelAndView handleGetView() { ModelAndView mav = new ModelAndView();                    mav.setViewName("myjsp"); mav.addObject("someBean", someBean); return mav; }


Powered by Zendesk