相关疑难解决方法(0)

如何在春季启动时设置基本网址?

我想在一个弹簧启动项目中混合使用mvc和rest.

我想在一个地方为所有其他控制器(例如example.com/api)设置基本路径(我不希望@RequestMapping('api/products')仅为每个控制器添加注释@RequestMapping('/products').

可以通过example.com/whatever访问Mvc控制器

可能吗?

(我不使用spring数据休息,只是spring mvc)

java rest spring spring-mvc spring-boot

93
推荐指数
12
解决办法
14万
查看次数

设置swagger.ui.html的基本路径

有什么方法可以将Swagger 2内容移动到另一个基本URL?

我已经看到“ 如何为swagger 2.8.0做友好的基本URL ”以及这种解决方法:

@RequestMapping("/swagger")
public String greeting() {
    return "redirect:/swagger-ui.html";
}
Run Code Online (Sandbox Code Playgroud)

问题:

就我而言,这是不可能的!

我的服务器托管两个Web应用程序和一个REST api,这就是为什么我在这里遇到这个怪物的原因:

@Controller
public class ForwardController {

    @RequestMapping(value = "/sitemap.xml", method = RequestMethod.GET)
    public String redirectSitemapXml(HttpServletRequest request) {
        return "forward:/a/web/assets/sitemap.xml";
    }

    @RequestMapping(value = "/robots.txt", method = RequestMethod.GET)
    public String redirectRobotTxt(HttpServletRequest request) {
        return "forward:/a/web/assets/robots.txt";
    }

    @RequestMapping(value = "/*", method = RequestMethod.GET)
    public String redirectRoot(HttpServletRequest request) {
        return "forward:/a/web/index.html";
    }

    @RequestMapping(value = "/a/**/{path:[^.]*}", method = RequestMethod.GET)
    public String redirectClients(HttpServletRequest request) {

        String requestURI = request.getRequestURI(); …
Run Code Online (Sandbox Code Playgroud)

java swagger spring-boot

6
推荐指数
0
解决办法
1443
查看次数

标签 统计

java ×2

spring-boot ×2

rest ×1

spring ×1

spring-mvc ×1

swagger ×1