java - ${} variables not showing - Spring MVC -
i´m have maven project spring mvc, spring security , spring social.
when put message in jsp, show ${message}
instace of message.
i have jstl library.
my jsp:
<%@ page language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!doctype html> <html> <head> <meta charset="utf-8"> </head> <body> <script> var m = '${message}'; alert(m); </script> ${pagecontext.request.contextpath} <c:out value="${message}"></c:out> <br /><br /> ${message} <br /><br /> ${currentuserconnection.profileurl} <br /><br /> </body> </html>
my controller:
@controller public class logincontroller { @requestmapping(value = "/signup**") public modelandview signuphandler() { modelandview model = new modelandview("home"); model.setviewname("home"); model.addobject("message", "aa"); return model; } }
the web page show ${message}
instace of aa
. alert show ${message}
too
what can doing wrong? in advance.
edit 1:
the configuration in annotations. viewresolver:
@bean(name = "viewresolver") public internalresourceviewresolver viewresolver() { internalresourceviewresolver viewresolver = new internalresourceviewresolver(); viewresolver.setviewclass(jstlview.class); viewresolver.setprefix(viewprefix); viewresolver.setsuffix(viewsuffix); return viewresolver; }
solution:
the solution version of web xml need greater 2.5
thanks @m.deinum
make sure have correct jsp resolver spring context xml.
like:
<bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix" value="/web-inf/views/"/> <property name="suffix" value=".jsp"/> </bean>
and proper dispatcher servlet configuration in web.xml:
<servlet> <servlet-name>dispatcher</servlet-name> <servlet-class> org.springframework.web.servlet.dispatcherservlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
and old servlet 2.3 can add fallow jsp (see here) or ofc change web.xml new one:
<%@ page iselignored ="false" %>
edited.
Comments
Post a Comment