[英]Spring Web Services Class Not Found Exception
I'm going through this Spring tutorial online form springsource.org. 我将在线阅读springource.org的春季教程。
http://static.springsource.org/docs/Spring-MVC-step-by-step/part2.html http://static.springsource.org/docs/Spring-MVC-step-by-step/part2.html
In Chapter 2, at the end, it has you add a bean to prefix and suffix /WEB-INF/jsp/
and .jsp
to responses. 在第2章中,最后,您可以在前缀和后缀
/WEB-INF/jsp/
和.jsp
添加一个bean来响应。
The code so far should basically load index.jsp when you go to localhost:8080/springapp/ which will redirect to localhost:8080/springapp/hello.htm which creates an instance of the HelloController which should in theory send you over to /WEB-INF/jsp/hello.jsp. 到目前为止,代码基本上应该在转到localhost时加载index.jsp:8080 / springapp /将重定向到localhost:8080 / springapp / hello.htm,它创建一个HelloController的实例,理论上应该将你发送到/ WEB -INF / JSP / hello.jsp中。 When I added the prefix/suffix bean and changed all my references to just "hello" instead of the fully pathed jsp file, I started getting the following error:
当我添加前缀/后缀bean并将我的所有引用更改为“hello”而不是完全路径化的jsp文件时,我开始收到以下错误:
message Handler processing failed; nested exception is
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/fmt/LocalizationContext
I've tried going back through the samples several times and checking for typo's and I still can't find the problem. 我已经尝试过多次回顾样本并检查拼写错误,但我仍然找不到问题。 Any tips or pointers?
任何提示或指示?
index.jsp (in the root of the webapp: index.jsp(在webapp的根目录中:
<%@ include file="/WEB-INF/jsp/include.jsp" %>
<%-- Redirected because we can't set the welcome page to a virtual URL. --%>
<c:redirect url="/hello.htm" />
HelloController.java (minus the imports and package: HelloController.java(减去导入和包:
public class HelloController implements Controller {
protected final Log logger = LogFactory.getLog(getClass());
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String now = (new Date()).toString();
logger.info("Returning hello view with " + now);
return new ModelAndView("hello", "now", now);
}
}
My hello.jsp file: 我的hello.jsp文件:
<%@ include file="/WEB-INF/jsp/include.jsp" %>
<!DOCTYPE html>
<html>
<head>
<title>Hello :: Spring Application</title>
</head>
<body>
<h1>Hello - Spring Application</h1>
<p>Greetings, it is now <c:out value="${now}" /></p>
</body>
</html>
It seems like you are missing the JSTL jar here. 好像你在这里错过了JSTL jar。 Try downloading it and place it in your classpath to see if it works: Where can I download JSTL jar
尝试下载它并将其放在类路径中以查看它是否有效: 我在哪里可以下载JSTL jar
It seems certain required jar(s) are missing from classpath. 似乎某些必需的jar(s)在classpath中丢失了。 Make sure you have servlet-api-2.x.jar jsp-api-2.x.jar and jstl-1.x.jar on classpath
确保在类路径上有servlet-api-2.x.jar jsp-api-2.x.jar和jstl-1.x.jar
Please make sure the jstl.jar
file is located in your WEB-INF/lib
folder. 请确保
jstl.jar
文件位于WEB-INF/lib
文件夹中。
As a matter of fact, here is what is stated in the tutorial that you linked. 事实上,这是您链接的教程中所述的内容。 I guess you missed this step:
我想你错过了这一步:
We will be using the JSP Standard Tag Library (JSTL), so let's start by copying the JSTL files we need to our 'WEB-INF/lib' directory.
我们将使用JSP标准标记库(JSTL),所以让我们首先将我们需要的JSTL文件复制到'WEB-INF / lib'目录中。 Copy jstl.jar from the 'spring-framework-2.5/lib/j2ee' directory and standard.jar from the 'spring-framework-2.5/lib/jakarta-taglibs' directory to the 'springapp/war/WEB-INF/lib' directory.
将'spring-framework-2.5 / lib / j2ee'目录中的jstl.jar和'spring-framework-2.5 / lib / jakarta-taglibs'目录中的standard.jar复制到'springapp / war / WEB-INF / lib ' 目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.