Matching html resources with Spring Download

I am using Spring Boot to create a REST API for the site I am creating. For the time being, to access static content, I just go to the resource name. For example, /index.htmlor /dashboard.html. Since I use REST controllers, there is no way to map pages to specific URL endings and there is no file web.xmlsince I use Spring Boot. (for example, I want the /dashboardfile to display dashboard.html.)

Should I use standard MVC controllers @Controllerto control the display of my page, or is there a better way to do this?

EDIT

Now I can access the static content simply by typing the file name in the url. (for example, /index.htmlopen an index.)

I want to know how to reassign static content. For example, if I want to /dashboarddisplay dashboard.html, or I want to /errordisplay /error.html, etc ... It will make it easier / easier for the user to simply go to www.mydomain.com/dashboardinstead of adding the ending .html.

Is there a way to reassign such pages using Spring Boot?

EDIT 2

I want to take on the burden of creating representations of each page hosted on the client system. In other words, I do NOT want the server to create each page. I want to have “templates” in essence, which then turn into useful information pages. VIA REST API used by AngularJS controllers.

+4
3

Angular, Thymeleaf (Thymeleaf RESTful). $routeProvider, , URI. index.html , Spring Boot , URI, Angular, .

https://docs.angularjs.org/api/ngRoute/provider/ $routeProvider

0

Thymeleaf - HTML:

:

build.gradle

    dependencies {
    compile("org.springframework.boot:spring-boot-starter-thymeleaf")
}

:

GreetingController.java

@Controller
public class GreetingController {

    @RequestMapping("/greeting")
    public String greeting(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model) {
        model.addAttribute("name", name);
        return "greeting";
    }

}

:

name.html , , "greeting"

SRC////greeting.html

<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>Serving HTML Web Content</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
    <p>HEY THERE!</p>
</body>
</html>

, :

http://localhost:8080/greeting

+1
  • - index.html, angular.js bootstrap.js angular template.html node end proxy -, spring ( spring CORS).
  • , , nginx/httpd - spring .
0

Source: https://habr.com/ru/post/1659108/


All Articles