如何在 Maven Jetty 插件中设置 jstl

How to set jstl in Maven Jetty plugin

我做了一个简单的网络项目。为了便于使用,我使用了一个 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

使用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>