【问题标题】:How to set jstl in Maven Jetty plugin如何在 Maven Jetty 插件中设置 jstl
【发布时间】:2018-01-27 21:11:14
【问题描述】:

我做了一个简单的网络项目。为了便于使用,我使用了一个 maven jetty 插件,并多次尝试使用 jstl 库。原则上,该插件有一个内置的 jstl 库,实际上,虽然我没有明确包含 jstl-1.2.jar,但我的页面是编译好的。当我尝试使用 jstl 的功能时会出现问题。 示例jsp:

<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<html>
    <body>
        <h2>Hello World!</h2>
         <c:set var = "salary" scope = "session" value = "${2000*2}"/>
        <c:out value = "${salary}"/>
    </body>
</html>

预览:

我试过这种方法:

1)to include the library as a dependancy in my pom.xml -> the same result

2)to include the library in WEB-INF.lib -> the same result

3)to include jstl-1.2.jar as external jar in dependencies -> the same result

我使用的是 NetBeans 8.2

【问题讨论】:

    标签: java maven jetty jstl


    【解决方案1】:

    使用 maven jetty 插件时不需要包含 jstl 库。问题出在可以从 web.xml 配置的 Servlet 描述符中。 这个 web.xml 解决了我的问题:

    <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
             http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
             version="3.1">
    </web-app>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-30
      • 1970-01-01
      • 2016-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-24
      相关资源
      最近更新 更多