严重: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /WEB-INF/pages/svg/doc-svg/index.jsp(198,5) According to TLD or attribute directive in tag file, attribute key does not accept any expressions
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
at org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1174)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:821)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:840)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1736)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:183)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at com.fj.bsfra.web.DpoActionImp.include(DpoActionImp.java:599)
at com.fj.bsfra.web.HandlerJsp.process(HandlerJsp.java:12)
at com.fj.bsfra.web.Handler.doProcess(Handler.java:13)
at com.fj.bsfra.web.ActionProxy.doAction(ActionProxy.java:110)
at com.fj.bsfra.web.ActionProxy.execute(ActionProxy.java:55)
at com.fj.bsfra.web.ActionFilter.doFilter(ActionFilter.java:32)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:595)
错误原因:自定义标签不接收任何表达式
修改方法:
自定义标签中让标签属性正确接收EL表达式对象 Apache .
如何在Java自定义标签中让自定义的标签属性正确接收EL表达式对象
我们在项目开发中为了更方便灵活的使用Java自定义标签,往往需要让自定义的标签属性接收一些EL表达式对象,所幸的是apache为我们提供了简单的实现方式。
需要的jar包:
jstl.jar
standard.jar
其实这两个包就是我们在使用jstl时所需的两个包。
要接收EL表达式对象,首先得在标签的实现类文件中将这个属性的对象类型设置为Object类型,在set、get方法中,set方法需要引入apache的类:
import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
这个类中有一个evaluate 方法,当el表达式作为参数传入时,调用这个方法,在tag内即可自动把el表达式转化成所需要的对象。
你只需在set方法里如下调用:
public void setValue(Object value)throws JspException
{
this.value = ExpressionEvaluatorManager.evaluate(
"value", value.toString(), Object.class, this, pageContext);
}
ExpressionEvaluatorManager.evaluate有四个参数。
第一个表示tag的名字,在取el表达式出错时使用。一般和属性名字相同。
第二个要求字符串,通常简单调用输入对象的toString方法。
第三个是类,通常用Object.class。
第四个用this即可,
第五个是pageContext变量。
在tld文件中该标签属性的rtexprvalue得设置为true,表示是否支持运行时表达式取值。
OK啦!可以用啦!
org.apache.jasper.JasperException: /WEB-INF/pages/svg/doc-svg/index.jsp(198,5) According to TLD or attribute directive in tag file, attribute key does not accept any expressions
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
at org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1174)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:821)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:840)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1736)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:183)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at com.fj.bsfra.web.DpoActionImp.include(DpoActionImp.java:599)
at com.fj.bsfra.web.HandlerJsp.process(HandlerJsp.java:12)
at com.fj.bsfra.web.Handler.doProcess(Handler.java:13)
at com.fj.bsfra.web.ActionProxy.doAction(ActionProxy.java:110)
at com.fj.bsfra.web.ActionProxy.execute(ActionProxy.java:55)
at com.fj.bsfra.web.ActionFilter.doFilter(ActionFilter.java:32)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:595)
错误原因:自定义标签不接收任何表达式
修改方法:
自定义标签中让标签属性正确接收EL表达式对象 Apache .
如何在Java自定义标签中让自定义的标签属性正确接收EL表达式对象
我们在项目开发中为了更方便灵活的使用Java自定义标签,往往需要让自定义的标签属性接收一些EL表达式对象,所幸的是apache为我们提供了简单的实现方式。
需要的jar包:
jstl.jar
standard.jar
其实这两个包就是我们在使用jstl时所需的两个包。
要接收EL表达式对象,首先得在标签的实现类文件中将这个属性的对象类型设置为Object类型,在set、get方法中,set方法需要引入apache的类:
import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
这个类中有一个evaluate 方法,当el表达式作为参数传入时,调用这个方法,在tag内即可自动把el表达式转化成所需要的对象。
你只需在set方法里如下调用:
public void setValue(Object value)throws JspException
{
this.value = ExpressionEvaluatorManager.evaluate(
"value", value.toString(), Object.class, this, pageContext);
}
ExpressionEvaluatorManager.evaluate有四个参数。
第一个表示tag的名字,在取el表达式出错时使用。一般和属性名字相同。
第二个要求字符串,通常简单调用输入对象的toString方法。
第三个是类,通常用Object.class。
第四个用this即可,
第五个是pageContext变量。
在tld文件中该标签属性的rtexprvalue得设置为true,表示是否支持运行时表达式取值。
OK啦!可以用啦!