-6ren"> -试图找出等效的东西 @Bean配置将用于 XML 元素 谢谢! 最佳答案 将“/”请求转发到 Java 中名为“home”的 View 的示例: @Configuration @EnableWebM-6ren">
gpt4 book ai didi

spring-mvc - Spring Bean 配置相当于

转载 作者:行者123 更新时间:2023-12-03 14:15:13 26 4
gpt4 key购买 nike

试图找出等效的东西 @Bean配置将用于 XML 元素

<mvc:view-controller path="..." />

谢谢!

最佳答案

将“/”请求转发到 Java 中名为“home”的 View 的示例:

@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {

@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("home");
}

}

同样在 XML 中使用元素:
<mvc:view-controller path="/" view-name="home"/>

上面的例子复制自 Spring reference docs

关于spring-mvc - Spring Bean 配置相当于 <mvc :view-controller path ="..."/>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17049032/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com