代码之家  ›  专栏  ›  技术社区  ›  Santhosh

Spring MVC应用程序无法工作

  •  0
  • Santhosh  · 技术社区  · 12 年前

    我正在按照解释进行尝试 here ,但无法获取第二页显示的输出。 它重定向到第二页,但不打印我输入的文本,而是返回空白页。 有什么建议吗?我使用的是spring框架3.0.2。

    helloView.jsp

    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Hello</title>
    </head>
    <body>
        <h1>${helloMessage}</h1>
    </body>
    </html>
    

    名称View.jsp

    <%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Name</title>
        </head>
        <body>
            <h1>Enter your Name</h1>
           <spring:nestedPath path="name">
        <form action="" method="post">
            Name:
            <spring:bind path="value">
                <input type="text" name="${status.expression}" value="${status.value}">
            </spring:bind>
            <input type="submit" value="OK">
        </form>
    </spring:nestedPath>
        </body>
    </html>
    

    My project structure

    1 回复  |  直到 12 年前
        1
  •  1
  •   UI_Dev    12 年前

    添加此bean类

    <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
    

    该bean负责为文件中注册的所有控制器自动创建URL映射。它采用控制器的完全限定类名(在我们的例子中是controller.HelloController),去掉包名和controller后缀,然后将结果用作URL映射。