繁体   English   中英

Spring Web Services类未找到异常

[英]Spring Web Services Class Not Found Exception

我将在线阅读springource.org的春季教程。

http://static.springsource.org/docs/Spring-MVC-step-by-step/part2.html

在第2章中,最后,您可以在前缀和后缀/WEB-INF/jsp/.jsp添加一个bean来响应。

到目前为止,代码基本上应该在转到localhost时加载index.jsp:8080 / springapp /将重定向到localhost:8080 / springapp / hello.htm,它创建一个HelloController的实例,理论上应该将你发送到/ WEB -INF / JSP / hello.jsp中。 当我添加前缀/后缀bean并将我的所有引用更改为“hello”而不是完全路径化的jsp文件时,我开始收到以下错误:

message Handler processing failed; nested exception is 
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/fmt/LocalizationContext

我已经尝试过多次回顾样本并检查拼写错误,但我仍然找不到问题。 任何提示或指示?

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(减去导入和包:

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);
    }
}

我的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>

好像你在这里错过了JSTL jar。 尝试下载它并将其放在类路径中以查看它是否有效: 我在哪里可以下载JSTL jar

似乎某些必需的jar(s)在classpath中丢失了。 确保在类路径上有servlet-api-2.x.jar jsp-api-2.x.jarjstl-1.x.jar

请确保jstl.jar文件位于WEB-INF/lib文件夹中。

事实上,这是您链接的教程中所述的内容。 我想你错过了这一步:

我们将使用JSP标准标记库(JSTL),所以让我们首先将我们需要的JSTL文件复制到'WEB-INF / lib'目录中。 将'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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM