0

I am facing a problem with sending from to Spring controller. I try so many way but I just got this error

Neither BindingResult nor plain target object for bean name 'command' available as request attribute

Here is my jsp page..

<div class="container">

    <div class="row">
        <div class="col-md-4"></div>
        <div class="col-md-4 well well-lg">
            <spring:url value="/fetch/page" var="fetchPage" />
            <form:form method="get" action="${fetchPage}">
                <div class="center-block ">

                    <label class="control-label"> Name</label>
                    <form:input placeholder="Customer Name" class="form-control"
                        path="name" />
                </div>
                <br />
                <button type="submit" class="btn btn-primary">Save</button>

            </form:form>
        </div>
        <div class="col-md-4"></div>

    </div>
</div>

and here is my controller

    @RequestMapping(value = "/fetch/page/", method = RequestMethod.GET)
public String getPageFromjsp(@PathVariable("id") String name, Model model) {
    System.out.println(name);

    return "home";
}
sai aung myint soe
  • 139
  • 1
  • 1
  • 12
  • check if this helps.. http://stackoverflow.com/questions/8781558/neither-bindingresult-nor-plain-target-object-for-bean-name-available-as-request – Deendayal Garg Sep 12 '16 at 19:20
  • @DeendayalGarg Thanks. but I would like to only PathVariable. In my case, I just only need only string. So, I don't wanna create Model, if not necessary. – sai aung myint soe Sep 12 '16 at 20:00
  • 1
    '@PathVariable' is used when the value is part of the URL. e.g. domain.com/fecth/page/1 but in your case is different you're using something like this domain.com/fetch/page?id=1 in this case you can use '@RequestParam' instead of '@PathVariable' – reos Sep 12 '16 at 20:21
  • How can I write url in action to catch pathvariable? – sai aung myint soe Sep 12 '16 at 20:25
  • Your request mapping does not contain a path variable. – a better oliver Sep 13 '16 at 05:59

0 Answers0