且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将javascript文件编译为jsp?

更新时间:2023-11-10 17:49:10

Bozho给出了正确的提示.但是,我想回答具体问题.

Bozho gave the right hint. However, I'd like to answer the concrete problem.

当未在文件顶部声明fmt taglib时,给定的代码片段将失败:

The given code snippet will fail when the fmt taglib is not declared in top of file:

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:setLocale value="${language}" />
<fmt:setBundle basename="com.example.i18n.text" />

因此,只需确保它在JS文件中位于上方即可.

So just ensure that it is there above in your JS file.

JSP servlet条目看起来不错,尽管我想我会只使用以下内容:

The JSP servlet entry looks fine, although I think I would rather have used just this:

<servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>*.js</url-pattern>
</servlet-mapping>

(jsp是Tomcat内置JspServletservlet-name,您可以在其/conf/web.xml中找到它)

(jsp is the servlet-name of the Tomcat's builtin JspServlet which you can locate in its /conf/web.xml)