当前位置: 首页> 汽车> 时评 > SpringBoot设置自动跳转前端界面

SpringBoot设置自动跳转前端界面

时间:2025/7/11 14:53:39来源:https://blog.csdn.net/weixin_61898502/article/details/140108777 浏览次数: 0次

        一般情况下,我们的Application启动文件的内容为一行的运行代码,默认启动项目以后不会自动跳转到我们的前端页面

public static void main(String[] args) {SpringApplication.run(DemoApplication.class, args);}

        这里我的可以通过设置文件的内容,将Application文件的内容粘贴为一下内容可以使项目启动后直接跳转到前端页面(注意更改自己的路径)

public static void main(String[] args) {int port = 8080;String portPrefix = "--server.port=";for (String arg : args) {if (arg.startsWith(portPrefix)) {port = Integer.parseInt(arg.substring(portPrefix.length()));}}SpringApplication.run(SpringbootApplication.class, args);//注意更改成自己的路径try {Runtime.getRuntime().exec("cmd /c start http://localhost:" + port);} catch (IOException e) {e.printStackTrace();}}

关键字:SpringBoot设置自动跳转前端界面

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: