java 为什么jstl不起作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7579735/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why jstl is not working?
提问by Njax3SmmM2x2a0Zf7Hpd
Like in the article , I have placed the following files in WEB-INF/lib folder of my applicaion
就像在文章中一样,我将以下文件放在我的应用程序的 WEB-INF/lib 文件夹中
- Standard.jar (1.1.2)
- jstl.jar (1.1.2)
- 标准.jar (1.1.2)
- jstl.jar (1.1.2)
in taglib it states that it would resolve uri tag in the TLD of a taglib deployed in a jar file (WEB-INF/lib).
在 taglib 中,它声明它将解析部署在 jar 文件 (WEB-INF/lib) 中的 taglib 的 TLD 中的 uri 标记。
And my application keep throwing errors that it cannot found any tag libs.
而且我的应用程序不断抛出错误,无法找到任何标签库。
When I extracted the Standard.jar\MET-INF *.tld files under to WEB-INF\tld folder, It worked and sorted. But still is there a cleaner way I could do it, So I may not need to update that taglibs separately other than replacing it with the new version?
当我将 Standard.jar\MET-INF *.tld 文件解压缩到 WEB-INF\tld 文件夹下时,它工作并排序。但是仍然有一种更简洁的方法可以做到这一点,所以除了用新版本替换它之外,我可能不需要单独更新那些标签库?
Exception org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/corecannot be resolved in either web.xml or the jar files deployed with this application
异常 org.apache.jasper.JasperException:绝对 uri:http: //java.sun.com/jsp/jstl/core无法在 web.xml 或使用此应用程序部署的 jar 文件中解析
回答by byyyk
You probably don't have them in your build path. Placing them in libsfolder may not be sufficient. In Eclipse for example: right click on project -> Build Path-> Configure Build Path ...Then in Libraries tab add your jars using Add External JARsbutton.
您的构建路径中可能没有它们。将它们放在libs文件夹中可能还不够。例如在 Eclipse 中:右键单击项目 ->构建路径->配置构建路径...然后在库选项卡中使用添加外部 JAR按钮添加您的 jar 。
回答by BalusC
You should notextract the JAR files and clutter your webapp project with its loose contents. Remove them all. You should notmanually define the taglibs in web.xml
. Remove them all. You should notput them in some random /lib
folder and fiddle with IDE build path properties. Remove them all and undo the changed buildpath properties.
你应该不提取的JAR文件,并用其宽松的内容搞乱你的webapp项目。将它们全部删除。你应该没有手动定义标签库web.xml
。将它们全部删除。你应该不把他们在一些随机的/lib
文件夹,然后摆弄IDE构建路径属性。将它们全部删除并撤消更改的构建路径属性。
All you need to do is:
您需要做的就是:
Download the zip, extract it, open its
/lib
folder and copyjstl.jar
andstandard.jar
files in/WEB-INF/lib
folder (thus, not/lib
) of your webapp. A bit decent IDE should already have created the/WEB-INF/lib
folder for you. You just have to drop the JARs in there.Declare the taglibs with proper URI in JSPs as per the tag documentation. For JSTL 1.1 Core taglibit's the following
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
(note the
/jsp
in the path, this is often overlooked because old JSTL 1.0 didn't have this)
下载zip,提取它,打开它的
/lib
文件夹,复制jstl.jar
和standard.jar
文件/WEB-INF/lib
夹(因此,不是/lib
你的web应用)。有点像样的 IDE 应该已经/WEB-INF/lib
为您创建了该文件夹。你只需要把 JAR 放在那里。根据标记文档,在 JSP 中使用正确的 URI 声明标记库。对于JSTL 1.1 Core taglib,如下所示
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
(注意
/jsp
路径中的,这经常被忽视,因为旧的 JSTL 1.0 没有这个)
See also:
也可以看看:
回答by Kh?m L??ng
You can check file web.xml
您可以检查文件 web.xml
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
end in file .jsp add
以文件 .jsp 结尾添加
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
回答by Satya
you need to define the taglib's information in web.xml like :
您需要在 web.xml 中定义 taglib 的信息,例如:
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
and this uri name you can use in jap like :
您可以在 jap 中使用这个 uri 名称,例如:
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>