我面临着无法处理的 Spring Boot 配置问题......
我正在尝试使用 Spring Boot 为 HbbTV 构建一个 HelloWorld 示例,因此我需要使用 mime-type="application/vnd.hbbtv.xhtml+xml" 来服务我的“index.html”页面
例如,我的 index.html 将作为静态页面访问http://myserver.com/index.html?param=value.
使用以下代码,无论我多么努力,我都会得到 text/html 内容类型。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//HbbTV//1.1.1//EN" "http://www.hbbtv.org/dtd/HbbTV-1.1.1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>MyApp HBBTV</title>
<meta http-equiv="content-type" content="Content-Type: application/vnd.hbbtv.xhtml+xml; charset=UTF-8" />
</head>
<body>
...
</body>
</html>
因此,我尝试将“home()”端点添加到 @Controller 中以强制使用正确的 mime 类型,这很有效。
@RestController
public class HbbTVController {
@RequestMapping(value = "/hbbtv", produces = "application/vnd.hbbtv.xhtml+xml")
String home() {
return "someText";
}
...
}
“有效”意味着jetty服务器为我提供了一个html文件,该文件具有包含测试someText的正确内容类型。
我的下一个尝试是用 @Controller 替换 @RestController (相同produce配置),并将“someText”替换为索引.html
@Controller
public class HbbTVController {
@RequestMapping(value = "/hbbtv", produces = "application/vnd.hbbtv.xhtml+xml")
String home() {
return "index.html";
}
...
}
好吧,它正确地为我的index.html提供服务,但内容类型是错误的:text/html而不是application/vnd.hbbtv.xhtml+xml。
此外,我不想访问myserver.com/hbbtv来获取index.html,而是直接访问myserver.com/index.html。
我怎么能这么做呢?
谢谢...