Question

I am trying as explained here, but couldn't get the output that is shown for the second page. It redirects to the second page but doesn't print the text i entered, rather returns the empty page. Any suggestions ? i am using spring framework 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>

nameView.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

Was it helpful?

Solution

Add this bean class

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

This bean is responsible for automatically creating an URL mapping for all controllers registered in the file. It takes the fully-qualified class name of the controller (in our case, controller.HelloController) and strips the package name and Controller suffix, then uses the result as a URL mapping.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top