Skip to main content

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'xxx' available as request attribute

While trying to use Spring MVC form Tags, I come across following exception


java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'userInput' available as request attribute

Below is my JSP Code with Spring Tags

<%@page contentType="text/html" pageEncoding="UTF-8" session="false" %>
<%@taglib uri="http://www.springframework.org/tags" prefix="st"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="sf"%>
<!DOCTYPE html>
<html>
    
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>About Us Page</title>        
        <st:url var="bootstrapp_theme" value="/resources/css/bootstrap-theme.css" />
        <st:url var="bootstrapp_css" value="/resources/css/bootstrap.css" />
        <st:url var="jquery" value="/resources/js/jquery-2.2.0.js" />
        <st:url var="bootstrapp_js" value="/resources/js/bootstrap.js" />
        <link href="${bootstrapp_theme}" rel="stylesheet" />
        <link href="${bootstrapp_css}" rel="stylesheet" />        
        <script src="${jquery}" ></script>
        <script src="${bootstrapp_js}" ></script>
        
        
    <body>
        <h1 class="text-center">ABC CORPORATION</h1>
        
        <sf:form method="POST" action ="/SpringBasics/redirect">
            
            <table>
                <tr>
                
                    <td>Login ID: &nbsp;&nbsp;<input type="text" name="userName" />
                       <br> Email: &nbsp;&nbsp;<sf:input type="email" path="email" />
                       <br> My Label: &nbsp;&nbsp;<sf:label id="lbl1" path="myLabel"   />
                         
                    </td>
                </tr>
                <tr>
                    
                    <td>Password:&nbsp;&nbsp;<input type="number"  name="extension" /></td>
                </tr>
            </table>


            <input type="submit" value="Redirect Page" />
        </sf:form>
    </body>
</html>


To  resolve it I created a properties class which is defined below


package springbasics;



/**
 *
 * @author Zeeshan
 */

public class userInput {

    protected String _email;

    protected String _myLabel;

    public String getMyLabel() {
        return _myLabel;
    }

    public void setMyLabel(String _myLabel) {
        this._myLabel = _myLabel;
    }

    public String getEmail() {
        return _email;
    }

    public void setEmail(String _email) {
        this._email = _email;
    }


}

and change my JSP Code from 
        
<sf:form method="POST" action ="/SpringBasics/redirect">

To

<sf:form method="POST" action ="/SpringBasics/redirect" modelAttribute="userInput" >


Also change my controller class parameter From 

@RequestMapping(value = "/", method = GET)
    public String aboutUs() {     
        return "aboutus";      
    }

To

@RequestMapping(value = "/", method = GET)
    public String aboutUs(userInput obj) {     
        return "aboutus";      
    }


This resolve the above error message. 

If suggested solution help you in solving your issue then please comment to increase its credibility.

Thanks.


Comments

Popular posts from this blog

The sign-in method you're trying to use isn't allowed. For more info, contact your network administrator

Above problem occur when you have not added a group (of which User try to login)  in your local policy login. To resolve the issue, follow the steps,
Log in as the administrator on the server, then start the Group Policy Management Editor by running the  gpmc.msc command from PowerShell or the Command Line window. 1. In the Group Policy Management window on the left hand side, select Group Policy Management. 2. Click to expand the  Forest tree node.
3. Click Domains.
4. Select your domain name.
5. Click Group Policy Objects. 6. In the right-hand window, double-click Default Domain Controllers Policy.
7. Right-click Default Domain Controllers Policy and Select Edit.
8. In the Group Policy Management Editor window, click Default Domain Controllers Policy.
9. Click Computer Configuration, and then click Policies.
10. Click Windows Settings, and then click Security Settings. 11. Click Local Policies and then click User Rights Assignments.
12. In the right pane, click Allow log on locally. 12. Cli…

ORA-38104: Columns referenced in the ON Clause cannot be updated

In my case, this error pertains to Oracle Merge query. After 30 minutes of time wastage and a lot of hunting on different forums, I come to know that where and why was my merge query throwing exception.

I was giving multiple criteria in ON clause of merge query, and was also trying to update a column which I have mentioned in ON clause. Once I remove that column from update clause of merge query, it executed successfully.

I hope that this will also works for you.

In case if this post help you, then please comment on it.

Thanks.

Cannot use the special principal 'sa'. (Microsoft SQL Server, Error: 15405)

Yesterday, I start SQL Server 2005 and try to connect with sa user but was enable to connect with the 'sa' user and got this error:

Cannot use the special principal 'sa' (Microsoft SQL Server, Error: 15405)After doing some google, I found out the solution which I am sharing so that others can get all the possible solutions from this article.
The titled message mean that your sa user is disabled. To enable it, you have to follow below mentioned steps:1) you have to change the authentication mode: go to Management Studio and open Object Explorer. Connect to your server and right-click on the server name, then select Properties. Go to Security tab and under Server Authentication select "SQL Server and Windows Authentication Mode".2) Also, after you follow the directions above, you will also need to explicitly enable the sa account as well. Go to Security->Logins. Right-click on the "sa" account, select "Properties". In the list on the lef…