Jetty 8.x, 9. x cannot load jstl PWC6188, jstlpwc6188
Refer:
Cannot load JSTL taglib within embedded Jetty server: http://stackoverflow.com/questions/2151075/cannot-load-jstl-taglib-within-embedded-jetty-server
How do you get embedded Jetty 9 to successfully resolve the jstl uri? : Bytes;
JSTL core labels used: http://www.cnblogs.com/lihuiyy/archive/2012/02/24/2366806.html
JSP Expression Language: http://blog.csdn.net/csuliky/article/details/2452207
Using Spring3.2 MVC with embedded jetty9: http://stackoverflow.com/questions/19169377/using-spring3-2-mvc-with-embedded-jetty9
1. Brief Introduction
<% @ Page language = "java" contentType = "text/html; charset = ISO-8859-1" pageEncoding = "ISO-8859-1" isELIgnored = "false" %>
<% @ Taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
The preceding exception can be solved by adding corresponding statements on the page. However, the above problems still occur when the embedded Jetty is used here.
Add the above Code before jetty starts. The problem is that Jetty cannot load the JSTL class library. This is a bug
2. Jetty dependency
<Dependency>
<GroupId> org. eclipse. jetty </groupId>
<ArtifactId> jetty-webapp </artifactId>
<Version> 9.0.7.v20131107 </version>
<Scope> test </scope>
</Dependency>
<Dependency>
<GroupId> org. eclipse. jetty </groupId>
<ArtifactId> jetty-servlet </artifactId>
<Version> 9.0.7.v20131107 </version>
<Scope> test </scope>
</Dependency>
<Dependency>
<GroupId> org. eclipse. jetty </groupId>
<ArtifactId> jetty-jsp </artifactId>
<Version> 9.0.7.v20131107 </version>
</Dependency>
3. Run the code
Public class JettyServer {
Public static void main (String [] args) throws Exception {
System. setProperty ("DWPROJECTNO", "resource ");
System. setProperty ("DWENV", "dev ");
StartJettyServer (80 ,"/");
}
/**
* Create a Jetty Server for normal running and debugging, and use src/main/webapp as the Web application directory.
*
* @ Throws Exception
*/
Public static void startJettyServer (int port, String contextPath) throws Exception {
/* Fix jetty8.x, jetty 9.x can't load jstl library */
Field f = TldScanner. class. getDeclaredField ("systemUris ");
F. setAccessible (true );
(Set <?>) F. get (null). clear ();
F. setAccessible (false );
Server server = new Server (port );
WebAppContext webContext = new WebAppContext ("src/main/webapp", contextPath );
WebContext. setClassLoader (Thread. currentThread (). getContextClassLoader ());
WebContext. setDefaultsDescriptor ("src/test/resources/jetty-webdefault.xml ");
Server. setHandler (webContext );
Server. setStopAtShutdown (true );
Server. start ();
Server. join ();
}
}