One, configure vue packaging parameters
Assuming that the context-path of springboot is /, which is the root path, then I need to allocate a route for static resources. Here, taking pages as an example, the front-end vue.config.js configuration is as follows:
publicPath: '/pages/',
outputDir: 'dist',
assetsDir: 'static',
Two, springboot series configuration and processing
Configure the context-path as the root path /, and set the permission framework such as shiro to ignore pages permission interception. The project configuration based on the diboot low-code development platform is as follows:
server.servlet.context-path=/ diboot.iam.anon-urls=/pages/**
- Put the folders and files in the dist packaged in the front end into the resource/static/pages directory of the springboot project, as follows:
- Visit localhsot:8080/pages/index.html to succeed
3. Access path optimization:
The above scheme can only be accessed by visiting the routes of pages every time, so can we redirect to here? Yes.
Add the following controller code to automatically redirect from the root path to the above path:
@RestController public class RootRedirectController { @GetMapping("/") public void redirect(HttpServletResponse response) throws Exception { response.sendRedirect("/pages/index.html"); } }
The added permission framework ignores permission checks on the root path. The project configuration based on the diboot low-code development platform is as follows:
diboot.iam.anon-urls=/,/pages/**
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。