我需要爲Google App Engine項目註冊自定義ELResolver
。GAE/J:無法註冊自定義ELResolver
由於收到的任何請求之前,必須先進行註冊,as specified by the Javadoc:
It is illegal to register an ELResolver after the application has received any request from the client. If an attempt is made to register an ELResolver after that time, an IllegalStateException is thrown.
我使用的ServletContextListener:
public class RegisterCustomELResolver implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent sce) {
ServletContext context = sce.getServletContext();
JspApplicationContext jspContext =
JspFactory.getDefaultFactory().getJspApplicationContext(context);
jspContext.addELResolver(new MyELResolver());
}
...
}
的問題是,JspFactory.getDefaultFactory()
回報總是空。我已經填寫了一份錯誤報告。任何想法的解決方法?
不錯!現在我得到一個'java.lang.AbstractMethodError:javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;'異常。 JSP版本是2.0,其中'getApplicationContext()'是爲JSP 2.1定義的。我絕對不走運 – dfa 2010-03-31 12:21:15
'ELResolver'也是JSP 2.1。 GAE真的是JSP 2.0嗎?我期望它是JSP 2.1。你的'web.xml'聲明爲Servlet 2.5嗎?示例在這裏:http://snipplr.com/view/3775/minimal-webxml-webapp-descriptor-version-25/ – BalusC 2010-03-31 12:27:10
2.5,當然:) – dfa 2010-03-31 13:18:55