参考:

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();

}

}

最新文章

  1. 一步一步使用ABP框架搭建正式项目系列教程
  2. C#中的new修饰符
  3. Bootstrap弹出框(modal)垂直居中
  4. docker -v挂载数据卷网络异常的问题
  5. STL中算法
  6. 06-Java 本地文件操作
  7. 转:C++ 性能测试支持
  8. 《算法问题实战策略》-chaper14-整数论
  9. 成为一名优秀的C程序员
  10. 用C#实现的两个试验编程(txt文本数据的导入,和数据导出为TXT)
  11. ASP.NET Core Api网关Ocelot的中文文档
  12. input 上报流程图
  13. 一. 优化小程序自身的Storage
  14. springboot第一个项目【mybatis】
  15. (4)top详解 (每周一个linux命令系列)
  16. Android避免OOM(内存优化)
  17. Spring学习笔记2:Spring HelloWorld
  18. 质控工具之TrimGalore使用方法
  19. linux重命名所有find查找到的文件/文件夹
  20. Jmeter分布式

热门文章

  1. Linux常用命令之sed
  2. BZOJ 3713
  3. C#之使用随机数
  4. Javascript中关于数组的认识
  5. 邮箱格式验证demo
  6. 自定义View(一)-ViewGroup实现优酷菜单
  7. 通过Scrapy抓取QQ空间
  8. php nginx fastdfs 下载文件重命名
  9. asp.net中c# TextBox.MaxLength例子
  10. SQL中各数据类型的长度、精度