模板文本中不允许

模板文本中不允许

本文介绍了org.apache.jasper.JasperException:模板文本中不允许#{...}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用JSP和Spring MVC在浏览器屏幕上显示一条简单的消息.

I was trying to display a simple message on browser screen with JSP and Spring MVC.

<h2>#{message}</h2>

但是,它引发了以下异常:

However, it threw the below exception:

org.apache.jasper.JasperException: /Ekle/DomainEkle.jsp (line: 9, column: 6) #{...} is not allowed in template text
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:443)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:103)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:733)
org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:954)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
org.apache.jasper.compiler.Node$Root.accept(Node.java:475)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1798)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:217)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)

这是怎么引起的,我该如何解决?

How is this caused and how can I solve it?

推荐答案

使用

  <h2>${message}</h2>

代替

  <h2>#{message}</h2>

${...}是JSP中使用的表达语言,请在此处

The ${...} is the expression language used in JSP, check more here

#{...}是与JSF技术相关的表达语言,请在此处进行查看.

The #{...} is the expression language related to JSF technology, check more here

这篇关于org.apache.jasper.JasperException:模板文本中不允许#{...}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 15:09