gpt4 book ai didi

spring - 使用 Spring MVC 更改 Roo 生成的应用程序的默认主页

转载 作者:行者123 更新时间:2023-12-01 15:11:49 24 4
gpt4 key购买 nike

默认情况下,当网络应用程序启动时,它从 roo 生成的主页开始, View 名称为“index”

假设我使用以下命令添加新的自定义 Controller ,

web mvc controller ~.web.ViewHomeController --preferredMapping /homepage1

它生成如下代码,

@RequestMapping("/homepage1/**")
@Controller

public class ViewHomeController {
@RequestMapping
public void get(ModelMap modelMap, HttpServletRequest request,
HttpServletResponse response) {
}

@RequestMapping(method = RequestMethod.POST, value = "{id}")
public void post(@PathVariable Long id, ModelMap modelMap,
HttpServletRequest request, HttpServletResponse response) {
}

@RequestMapping
public String index() {
return "home/homepage1";
}
}

我希望“home/homepage1”页面成为 Roo 应用程序启动时显示的默认页面。

我能否获得一些指导/详细信息,了解我需要进行哪些更改才能使“home/homepage1”成为我的应用程序的默认主页。

提前感谢您的帮助。我使用的是最新版本的 Spring ROO,1.1.4。

谢谢

最佳答案

在您的 webmvc-config.xml 中,替换以下部分:

<!-- selects a static view for rendering without the need for an explicit controller -->
<mvc:view-controller path="/" view-name="index" />

使用您喜欢的 View 名称。

关于spring - 使用 Spring MVC 更改 Roo 生成的应用程序的默认主页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6566012/

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