Jquery 简单操作选项卡在 jsp 中不起作用
我正在尝试 jquery 选项卡,用户可以在其中添加选项卡和删除选项卡。我在这里找到了一个适合我需求的选项卡:
http://jqueryui.com/demos/tabs/#manipulation
我在开始的jsp页面中尝试了这个。当我运行应用程序时,它抛出一个异常,告诉:
服务器遇到内部错误()这阻止了它从满足这个请求。
异常
org.apache.jasper.JasperException: /Items.jsp(34,32) #{...} is not allowed in template text
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:102)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:706)
org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:958)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1763)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:347)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
行 (34,32) 有
<a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close'>Remove Tab</span>
但是当我将代码粘贴到 html 页面中时它运行得很好.. 为什么会有这种行为?谁能解释一下 谢谢:)
I was trying out jquery tabs where the user can add tabs and remove tabs.I found one suiting to my needs here:
http://jqueryui.com/demos/tabs/#manipulation
I tried this out in a jsp page in the starting.When I run the app it throws an exception telling:
The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /Items.jsp(34,32) #{...} is not allowed in template text
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:102)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:706)
org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:958)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1763)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:347)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
The line (34,32) has
<a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close'>Remove Tab</span>
But when I pasted the code in an html page it runs just fine..
Why is this behaviour?? Can anyone explain
Thanks:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题是 JSP 使用表达式语言 (EL) 标记
${}
来表示变量和类。虽然#{}
不是 JSP EL 标记,但它是其后继 Facelets 的标记,并且会抛出错误,指出 JSP 中不允许这样做。您将必须使用其他方法来定义将在正则表达式替换中替换的变量部分。而不是使用
尝试类似的方法
并将正则表达式替换行从
更改为
The problem is JSPs use expression-language (EL) tags
${}
for variables and classes. While#{}
isn't the JSP EL tag, it is the tag for it's successor, Facelets and it throws the error saying it isn't allowed in JSPs. You will have to use some other method to define your variable section that will be replaced in the regex replace.Instead of using
try something like
and change the regex replace line from
to
尝试用
Try with