代码之家  ›  专栏  ›  技术社区  ›  xyz

如何在Maven Jetty插件中设置jstl

  •  0
  • xyz  · 技术社区  · 7 年前

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

    预览:

    enter image description here

    我尝试了以下方法:

    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

    1 回复  |  直到 7 年前
        1
  •  0
  •   xyz    7 年前

    使用maven jetty插件时,不需要包含jstl库。问题出在可以从web配置的Servlet描述符中。xml。 此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>