i trying create minimal reproduction of spring mvc project use in diagnosing errors in more complex projects. when try click on url triggers controller method, eclipse console gives error indicating modelandview null. while this other question asks similar error, can see question not answered because 4 separate people gave +1 comment answer needs elaborated upon. looked @ this other posting, following it's advice of using org.springframework.web.servlet.modelandview
instead of map did not resolve problem. also, use map if possible, because map works in more complex apps. how can resolve error?
here controller method being called when error thrown:
@requestmapping(value = "/triggertheerror", method = requestmethod.get) public string processfindform(httpservletrequest request, bindingresult result, map<string, object> model) { return "reproduceerror"; }
the console prints out following log when above-controller method called:
13:59:10.874 [http-nio-8080-exec-3] debug o.s.web.servlet.dispatcherservlet - dispatcherservlet name 'minimaldbaseexample' processing request [/minimaldbaseexample/triggertheerror] 13:59:10.874 [http-nio-8080-exec-3] debug o.s.w.s.m.m.a.requestmappinghandlermapping - looking handler method path /triggertheerror 13:59:10.874 [http-nio-8080-exec-3] debug o.s.w.s.m.m.a.requestmappinghandlermapping - did not find handler method [/triggertheerror] 13:59:10.875 [http-nio-8080-exec-3] debug o.s.w.s.h.simpleurlhandlermapping - matching patterns request [/triggertheerror] [/**] 13:59:10.875 [http-nio-8080-exec-3] debug o.s.w.s.h.simpleurlhandlermapping - uri template variables request [/triggertheerror] {} 13:59:10.875 [http-nio-8080-exec-3] debug o.s.w.s.h.simpleurlhandlermapping - mapping [/triggertheerror] handlerexecutionchain handler [org.springframework.web.servlet.resource.defaultservlethttprequesthandler@186a461c] , 1 interceptor 13:59:10.875 [http-nio-8080-exec-3] debug o.s.web.servlet.dispatcherservlet - last-modified value [/minimaldbaseexample/triggertheerror] is: -1 13:59:10.875 [http-nio-8080-exec-3] debug o.s.web.servlet.dispatcherservlet - null modelandview returned dispatcherservlet name 'minimaldbaseexample': assuming handleradapter completed request handling 13:59:10.875 [http-nio-8080-exec-3] debug o.s.web.servlet.dispatcherservlet - completed request
answer
the solution remove bindingresult because not needed in situation. removing bindingresult arguments controller method, error removed. later on, if bindingresult required, solution add other required elements bindingresult not required test case.
i mark other user's answer accepted. however, preceding paragraph solution resolved problem.
if meant return string reproduceerror
, mark return value @responsebody
.
on other hand, if you've got view called reproduceerror
perhaps view resolver isn't configured properly?
edit: ok, looks rendering of reproduceerror
view intended, logfile seems controller method isn't being hit.