发生与 Eclipse 中 Spring MVC 应用程序的构建路径相关的错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9277073/
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
Error occuring related to build path in eclipse for Spring MVC application
提问by AbdulAziz
I am building MVC CRUD application. In JSP file I got this error
我正在构建 MVC CRUD 应用程序。在 JSP 文件中,我收到此错误
The tag handler class for "fmt:message"
(org.apache.taglibs.standard.tag.rt.fmt.MessageTag)
was not found on the Java Build Path
Here is my JSP file at the line "fmt:message"
这是我的 JSP 文件在“fmt:message”行
<%@ include file="/WEB-INF/jsp/include.jsp" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
<title><fmt:message key="title"/></title>
<style>
.error { color: blue; }
</style>
</head>
<body>
<h1><fmt:message key="addprod.heading"/></h1>
<form:form method="post" commandName="addprod">
<table width="95%" bgcolor="f8f8ff" border="0" cellspacing="0" cellpadding="5">
<tr>
<td align="right" width="20%">Add a new Product: (Please enter ID for the new product) </td>
<td width="20%">
<form:input path="productID"/>
</td>
<td width="60%">
<form:errors path="productID" cssClass="error"/>
</td>
</tr>
<tr>
<td align="right" width="20%">Add a new Product: (Please enter name for the new product) </td>
<td width="20%">
<form:input path="productname"/>
</td>
<td width="60%">
<form:errors path="productname" cssClass="error"/>
</td>
</tr>
<tr>
<td align="right" width="20%">Add Price: (Specify price in number) </td>
<td width="20%">
<form:input path="productprice"/>
</td>
<td width="60%">
<form:errors path="productprice" cssClass="error"/>
</td>
</tr>
</table>
<br>
<input type="submit" align="center" value="Add">
</form:form>
<a href="<c:url value="hello.htm"/>">Home</a>
</body>
</html>
Kindly guide me how to solve it. I added all the jars related, But could not understand the error exactly. Thanks
请指导我如何解决它。我添加了所有相关的罐子,但无法完全理解错误。谢谢
回答by Palpatim
I see two potential problems.
我看到了两个潜在的问题。
Regarding the specific error you're seeing, you need to ensure the appropriate tag library is on your build path. In Eclipse, right-click your project and select "Properties". In the dialog that pops up, select "Java Build Path". The window should display tabs representing the various kinds of libraries you can add to your project. One of those tabs should list the "JSTL" library--my projects, for instance, use
jstl-1.2.jar
. If you don't see it in any of the libraries on your build path, you may need to add it manually by copying it to your project's external library folder and adding the JAR manually to your build path.See: http://wiki.eclipse.org/FAQ_How_do_I_add_an_extra_library_to_my_project%27s_classpath%3Ffor more info.
After you add the library to your build path, you still have to make sure that the tags it contains are available to your specific JSP. In your example, you have:
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
That allows you to use Spring's
form
tag library in your current JSP. I do not see a similar declaration for thefmt
library, which I would expect to look something like:<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
It's possible that you've got that in your
include.jsp
file; if so you should be fine.
关于您看到的特定错误,您需要确保构建路径上有适当的标记库。在 Eclipse 中,右键单击您的项目并选择“属性”。在弹出的对话框中,选择“Java Build Path”。该窗口应显示代表您可以添加到项目中的各种库的选项卡。这些选项卡之一应该列出“JSTL”库——例如,我的项目使用
jstl-1.2.jar
. 如果在构建路径上的任何库中都没有看到它,则可能需要通过将其复制到项目的外部库文件夹并手动将 JAR 添加到构建路径来手动添加它。有关更多信息,请参阅:http: //wiki.eclipse.org/FAQ_How_do_I_add_an_extra_library_to_my_project%27s_classpath%3F。
将库添加到构建路径后,您仍然必须确保它包含的标记可用于您的特定 JSP。在您的示例中,您有:
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
这允许您
form
在当前的 JSP 中使用 Spring 的标记库。我没有看到fmt
库的类似声明,我希望它看起来像:<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
您的
include.jsp
文件中可能已经有了它;如果是这样你应该没问题。
Hope this helps.
希望这可以帮助。