Spring mvc requested resource is not available -


application , browser cannot render resource of app. saw lot of similar questions , not find solution. app works fine through json(ie without view)

there config

@configuration @enablewebmvc @componentscan("ru.practice.web") public class chatlocalwebconfig extends webmvcconfigureradapter {  @bean  public viewresolver viewresolver() {    internalresourceviewresolver resolv = new internalresourceviewresolver();    resolv.setprefix("web-inf/views/");    resolv.setsuffix(".jsp");    resolv.setviewclass(jstlview.class);    return resolv;    }  } 

initializer

public class chatlocalinitializer extends abstractannotationconfigdispatcherservletinitializer { @override protected string[] getservletmappings() {   return new string[] { "/" }; }   @override protected class<?>[] getrootconfigclasses() { return new class<?>[] { chatlocalwebconfig.class }; }  @override protected class<?>[] getservletconfigclasses() { return new class<?>[] { chatlocalwebconfig.class }; }  } 

controller

@controller @requestmapping("/user") public class usercontroller {  @autowired userrepository userrepository;  @requestmapping(value = "/",method = requestmethod.get) public string sayhello(model model) { model.addattribute("greeting", "hello world"); return "welcome"; } } 

and project structure image

i think it's resource path problem. change

resolv.setprefix("web-inf/views/");

to resolv.setprefix("/web-inf/views/");

and see how works.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -