use*_*663 9 java rest spring spring-mvc thymeleaf
例如,我有一个基本的 POST,它使用 Thymeleaf 返回一个名为“result”的 html。这很有效而且很酷。
@PostMapping("/greeting")
public String greetingSubmit(@ModelAttribute Greeting greeting) {
return "result";
}
Run Code Online (Sandbox Code Playgroud)
但我有另一个完全不相关的方法,它执行不同的操作,并且不返回模板。
@PostMapping(value = "/otherstuff", headers = "content-type=multipart/*")
public Object otherStuff(@RequestParam("file") MultipartFile dataFile) {
// Totally unrelated stuff
return resultList;
}
Run Code Online (Sandbox Code Playgroud)
当然,我得到一个例外:
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/otherstuff", template might not exist or might not be accessible by any of the configured Template Resolvers
Run Code Online (Sandbox Code Playgroud)
因为我故意不解析模板。我可以关闭此方法的 ThymeLeaf 吗?我的 Rest API 是多用途的,如果 ThymeLeaf 最终破坏了整个项目,那将毫无帮助。
谢谢。
| 归档时间: |
|
| 查看次数: |
2097 次 |
| 最近记录: |