星空网 > 软件开发 > Java

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.  server.setHandler(webContext);

  server.setStopAtShutdown(true);

  server.start();

  server.join();

}

}




原标题:jetty 8.x, 9.x无法加载jstl的PWC6188问题

关键词:JS

JS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

从一个类目的选品(自行车相关产品)来看看选品过程中的机会和风险:https://www.ikjzd.com/articles/137778
eBay:假日期间送达延误可能不会影响卖家帐号表现评级:https://www.ikjzd.com/articles/137779
每日新闻 20201221|中国汽车制造商奇瑞着重关注沙特阿拉伯市场:https://www.ikjzd.com/articles/137780
GBC代理新品牌发新案:https://www.ikjzd.com/articles/137781
亚马逊爆款按这个思路选就对了!:https://www.ikjzd.com/articles/137782
亚马逊各类邮件回复模板:https://www.ikjzd.com/articles/137783
价格翻了8倍,居然还有人买,秘诀在这里。:https://www.kjdsnews.com/a/1836642.html
欧洲B2B电商市场有待挖掘!销售总额将达1.7万亿欧元:https://www.kjdsnews.com/a/1836643.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流