Java 第二个控制器可以';找不到.html
第一个控制器工作正常Java 第二个控制器可以';找不到.html,java,spring,spring-boot,Java,Spring,Spring Boot,第一个控制器工作正常 @Controller @ComponentScan @EnableAutoConfiguration public class MainController { @RequestMapping("/profile") private String g(){ return "Profile.html"; } } 第二: @Controller @RequestMapping(value = "/gallery") public class
@Controller
@ComponentScan
@EnableAutoConfiguration
public class MainController {
@RequestMapping("/profile")
private String g(){
return "Profile.html";
}
}
第二:
@Controller
@RequestMapping(value = "/gallery")
public class GContoller {
@RequestMapping(value = "/month")
String ffff() {
return "monthGallery.html";
}
@RequestMapping("/test")
@ResponseBody
String test() {
return "Test";
}
}
页面localhost:8080/gallery/test
打开并显示“test”,但localhost:8080/gallery/month
打开时出现404错误。显然,第二个控制器找不到monthGallery.html文件。所有HTML都在/webapp中
项目结构
/java
/com.example.xxx
/webapp
尝试将以下注释添加到Gcontroller.java类:@ComponentScan@EnableAutoConfigurationIt没有帮助。我尝试了DPLS共享异常trace@DarkKnight没有例外。浏览器中只有404。如果通过@EnableWebMvc exception注释第二个控制器:无法在名为“dispatcherServlet”的servlet中解析名为“monthGallery”的视图
@Leonid您是否使用thymeleaf渲染视图?你有一个叫做monthGallery.html的html吗?无论如何,只返回“monthGallery”而不返回..html