jetty 8.x, 9.x无法加载jstl的PWC6188问题
参考:
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?: http://stackoverflow.com/questions/17685330/how-do-you-get-embedded-jetty-9-to-successfully-resolve-the-jstl-uri;
JSTL核心标签使用:http://www.cnblogs.com/lihuiyy/archive/2012/02/24/2366806.html
JSP表达式语言: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. 简述
<%@ 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" %>
上述异常在tomcat等地方只需要在页面上添加相应的语句即可解决。但是这里使用的嵌入式Jetty时还是会出现上述问题。
在jetty启动前添加上面的代码。问题原因是Jetty无法加载JSTL类库。这是一个bug
2. Jetty依赖
<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. 运行代码
public class JettyServer {
public static void main(String[] args) throws Exception {
System.setProperty("DWPROJECTNO", "resource");
System.setProperty("DWENV", "dev");
startJettyServer(80, "/");
}
/**
* 创建用于正常运行调试的Jetty Server, 以src/main/webapp为Web应用目录.
*
* @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();
}
}
最新文章
- 一步一步使用ABP框架搭建正式项目系列教程
- C#中的new修饰符
- Bootstrap弹出框(modal)垂直居中
- docker -v挂载数据卷网络异常的问题
- STL中算法
- 06-Java 本地文件操作
- 转:C++ 性能测试支持
- 《算法问题实战策略》-chaper14-整数论
- 成为一名优秀的C程序员
- 用C#实现的两个试验编程(txt文本数据的导入,和数据导出为TXT)
- ASP.NET Core Api网关Ocelot的中文文档
- input 上报流程图
- 一. 优化小程序自身的Storage
- springboot第一个项目【mybatis】
- (4)top详解 (每周一个linux命令系列)
- Android避免OOM(内存优化)
- Spring学习笔记2:Spring HelloWorld
- 质控工具之TrimGalore使用方法
- linux重命名所有find查找到的文件/文件夹
- Jmeter分布式