【问题标题】:Change default homepage for Roo generated app using SpringMVC使用 Spring MVC 更改 Roo 生成的应用程序的默认主页
【发布时间】:2011-07-05 00:14:35
【问题描述】:

默认情况下,当 Web 应用启动时,它会从 roo 生成的主页开始,视图名称为“index”

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

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。

谢谢

【问题讨论】:

    标签: spring default spring-roo


    【解决方案1】:

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

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

    使用您喜欢的视图名称。

    【讨论】:

    • 再次感谢您的快速回复。这有帮助。
    • 完全同意 Kev!
    • 作为新用户还没有投票的权限。但我确实将答案标记为已接受。谢谢。
    • 您有权从第 0 天开始投票,只需点击问题旁边的向上箭头即可。
    猜你喜欢
    • 2010-09-06
    • 2011-07-05
    • 1970-01-01
    • 2014-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-10
    • 2012-03-20
    相关资源
    最近更新 更多