spring boot 重定向到html页面 [英] spring boot redirect to html page

查看:96
本文介绍了spring boot 重定向到html页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是springboot的一个控制器,我想写一个重定向到html页面的函数,但是总是404响应,下面是代码和属性.'

This is a controller of springboot, I want to write a function to redirect to an html page, but it always responded with 404, and here is the code and properties. '

@Component

@Controller

@RequestMapping("/Weixin")

public class KindlePocketController {

private static final long serialVersionUID = 1L;

@Autowired
private TextBookInfoSearchService searchService;

@RequestMapping("/homepage")
public String toIndex() {
    System.out.println("redirecting to homepage...");
    return "index";
}
}

'应用程序属性'

spring.view.prefix=/WEB-INF/views/

spring.view.suffix=.html

'

程序可以进入函数,输出正常.而 index.html 在这个路径中:/WEB-INF/views/index.html.还有其他配置吗?非常感谢

the program can get into the function and output is ok. And index.html is in this path:/WEB-INF/views/index.html. Is there any else configurations ? Thanks a lot

推荐答案

你的配置不正确,试试这个:

You got the incorrect configuration, try this:

spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.html

它的 spring.mvc.view.* 而不是 spring.view.*.

PS:使用 STS 或 InteliJ 提供的 Intelisense.

PS: Use the Intelisense provided by STS or InteliJ.

这篇关于spring boot 重定向到html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆