java - 未找到 Spring Web 服务类异常

标签 java spring jsp spring-ws spring-tool-suite

我正在浏览来自 springsource.org 的在线 Spring 教程。

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

在第 2 章的最后,它让您添加一个 bean 到前缀和后缀 /WEB-INF/jsp/.jsp 到响应。

到目前为止的代码基本上应该在您转到 localhost:8080/springapp/时加载 index.jsp ,它将重定向到 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。尝试下载它并将它放在类路径中以查看它是否有效:Where can I download JSTL jar

关于java - 未找到 Spring Web 服务类异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15490123/

相关文章:

java - 多个SessionFactory/TransactionManager : no session found for current thread

java - 错误 405 : Method not Allowed on DELETE and PUT

java - SessionFactory未初始化

java - Spring MVC - 从JSP表中删除记录

java - 如何避免在 Web 应用程序中对字符串进行硬编码

java - Spring Integration - 用于大容量应用程序的可靠 TCP

Java 所见即所得的 HTML 编辑器

Java:布、石头、剪刀 GUI

java - org.springframework.beans.factory.BeanCreationException : Error creating bean with name - Spring security

java - 尽管放置正确,但找不到 jSTL