J'utilise cette ligne de code sur la page jsp:
<tr>
<td> <form:label path="formDescription.daySchedule">
<spring:message code="label.input.daySchedule"/> </form:label>
</td>
<td> <form:input path="formDescription.daySchedule" placeholder="<spring:message code="label.input.dayScheduleExample"/>" />
</td>
<td><form:errors path="formDescription.daySchedule"/>
</td>
</tr>
Je veux utiliser la balise html placeholder
pour rendre l'exemple dans le champ de saisie, mais le problème que je souhaite pour le rendre sur différentes langues. Mais cela me donne une erreur lorsque j'essaie de rendre une page:
Aug 04, 2013 6:54:11 PM org.Apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [appServlet] in context with path [/web] threw exception [/WEB-INF/views/input.jsp(103,258) equal symbol expected] with root cause
org.Apache.jasper.JasperException: /WEB-INF/views/input.jsp(103,258) equal symbol expected
at org.Apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.Java:41)
at org.Apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.Java:407)
at org.Apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.Java:88)
at org.Apache.jasper.compiler.Parser.parseAttribute(Parser.Java:217)
at org.Apache.jasper.compiler.Parser.parseAttributes(Parser.Java:162)
at org.Apache.jasper.compiler.Parser.parseAttributes(Parser.Java:153)
at org.Apache.jasper.compiler.Parser.parseCustomTag(Parser.Java:1236)
at org.Apache.jasper.compiler.Parser.parseElements(Parser.Java:1450)
at org.Apache.jasper.compiler.Parser.parseBody(Parser.Java:1662)
at org.Apache.jasper.compiler.Parser.parseOptionalBody(Parser.Java:1002)
at org.Apache.jasper.compiler.Parser.parseCustomTag(Parser.Java:1274)
at org.Apache.jasper.compiler.Parser.parseElements(Parser.Java:1450)
at org.Apache.jasper.compiler.Parser.parse(Parser.Java:138)
at org.Apache.jasper.compiler.ParserController.doParse(ParserController.Java:239)
at org.Apache.jasper.compiler.ParserController.parse(ParserController.Java:102)
at org.Apache.jasper.compiler.Compiler.generateJava(Compiler.Java:197)
at org.Apache.jasper.compiler.Compiler.compile(Compiler.Java:372)
at org.Apache.jasper.compiler.Compiler.compile(Compiler.Java:352)
at org.Apache.jasper.compiler.Compiler.compile(Compiler.Java:339)
at org.Apache.jasper.JspCompilationContext.compile(JspCompilationContext.Java:594)
at org.Apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.Java:344)
at org.Apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.Java:391)
at org.Apache.jasper.servlet.JspServlet.service(JspServlet.Java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.Java:722)
at org.Apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.Java:304)
at org.Apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.Java:210)
at org.Apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.Java:684)
at org.Apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.Java:471)
at org.Apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.Java:402)
at org.Apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.Java:329)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.Java:238)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.Java:263)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.Java:1208)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.Java:992)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.Java:939)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.Java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.Java:936)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.Java:827)
at javax.servlet.http.HttpServlet.service(HttpServlet.Java:621)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.Java:812)
at javax.servlet.http.HttpServlet.service(HttpServlet.Java:722)
at org.Apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.Java:304)
at org.Apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.Java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.Java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.Java:107)
at org.Apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.Java:243)
at org.Apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.Java:210)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.Java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.Java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.Java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.Java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.Java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.Java:54)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.Java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:342)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.Java:150)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.Java:183)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.Java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:342)
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.Java:125)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.Java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.Java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.Java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.Java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.Java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.Java:259)
at org.Apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.Java:243)
at org.Apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.Java:210)
at org.Apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.Java:240)
at org.Apache.catalina.core.StandardContextValve.invoke(StandardContextValve.Java:164)
at org.Apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.Java:462)
at org.Apache.catalina.core.StandardHostValve.invoke(StandardHostValve.Java:164)
at org.Apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.Java:100)
at org.Apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.Java:562)
at org.Apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.Java:118)
at org.Apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.Java:395)
at org.Apache.coyote.http11.Http11Processor.process(Http11Processor.Java:250)
at org.Apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.Java:188)
at org.Apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.Java:166)
at org.Apache.Tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.Java:302)
at Java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.Java:1110)
at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.Java:603)
at Java.lang.Thread.run(Thread.Java:722)
Je pense que vous ne pouvez pas utiliser une balise à l'intérieur d'une autre balise. Essayez avec le langage d’expression JSP (EL):
<spring:message code="label.input.dayScheduleExample" var="dayScheduleExample"/>
<tr>
<td> <form:label path="formDescription.daySchedule">
<spring:message code="label.input.daySchedule"/> </form:label>
</td>
<td> <form:input path="formDescription.daySchedule" placeholder="${dayScheduleExample}" />
</td>
<td><form:errors path="formDescription.daySchedule"/>
</td>
</tr>
Cela fonctionne pour moi, j'ai ajouté l'espace réservé d'attribut avec javascript/jquery comme ci-dessous:
$("#myID").attr('placeholder', '<spring:message code="myCode"/>');
Je pense que votre balisage asp est faux ici:
placeholder="<spring:message code="label.input.dayScheduleExample"/>"
Remplacez-le par:
placeholder='<spring:message code="label.input.dayScheduleExample"/>'
À partir du printemps 3, les balises de formulaire prennent en charge les attributs dynamiques.