V
V
Valentine2016-03-02 00:52:36
Java
Valentine, 2016-03-02 00:52:36

How to properly configure ui-routing+Spring MVC?

Welcome all! When developing a resource, I ran into a problem with configuring routing. I use ui-routing on the client side. Everything is fine exactly until the moment you go to any part of the site not from the start page. That is, if you follow the link: mysite.com/catalog/unicorns , then the server will naturally give you only the nested view /catalog/unicorns, without pulling up either Js or css. How to build in this case the correct architecture so that it pumps out a full-fledged view? On the server side I use Spring MVC . I would also like to ask: if I return html, then was it the right decision not to set up the ViewResolver, but simply to specify the resources:

public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations("/");
    }

And already give pages in this way:
@RequestMapping(value = "/", method = RequestMethod.GET)
    public String welcome() {       
        return "index.html";
    }

Or, if I plan to give just an html page, should I make a ViewResolver for html and attach the ViewControllerRegistry ?
I would also like to know how to solve the css problem for nested views, i.e. those parts of the Html code that are returned using ui-routing-a (although everything is returned using the server, but I don’t even know how to put it more correctly). So far, I have only found a solution by adding the following library
. But, again, this will not help if the user does not enter from the main page.
ps I also can't understand why Spring Hateoas is used, I saw it in a couple of lessons, I sort of realized that it generates a link to a specific resource, but why? When is it useful?
A big thank you to everyone who helps figure this out!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EshBobrow, 2016-03-02
@EshBobrow

use a template engine with layout support, the same thymeleaf for example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question