【问题标题】:Why is my index not found by tomcat?为什么tomcat找不到我的索引?
【发布时间】:2016-09-10 01:59:18
【问题描述】:

我已经开发 grails 应用程序几年了,最近在将应用程序部署到 tomcat6 时遇到了一个奇怪的问题。我可以访问登录页面。我可以登录并获得身份验证。但是,当被重定向到我的索引页面时,我得到一个 404 /myapp/ 资源不可用。

有趣的是,我可以导航到应用程序中的其他页面并执行我需要的任何操作,但是当导航回主页时,它会返回 404 not found。

我搜索了已部署的视图目录,并且 index.gsp 存在于它应该在的位置。我的 spock 测试没有失败。我不知所措。两年多来,我没有修改我的家庭控制器或索引页面本身。我错过了什么?

我正在使用 grails 2.1.1 和 tomcat6

更新:

这是我的 UrlMappings.groovy:

class UrlMappings {

static mappings = {

    "/$controller/$action?/$id?" {
        constraints {
            // apply constraints here
        }
    }

    "/"(controller: "home",action:"index")
        //(view: "/index")

    // special mapping for jqgrid errors
    "500"(controller: "errors", action: "validation", exception: ValidationException)

    //"500"(controller: "errors")
    "500"(view: '/error')
    //"/searchable"(view:"/searchable/index")
    /*name homeView: "/bullMaster" {
        controller = "bullMaster"
        action = "index"
    }
   */
}

}

而我的 HomeController 是真正的基本控制器:

class HomeController {

def index =  {

    render(view:"index")
}

def termsAndConditions ={
    render(view:"termsAndConditions")
}

}

我通常通过以下方式导航到应用程序:

http://ipAddress:8080/appName/

【问题讨论】:

  • 一个疯狂的镜头,但有没有可能,你删除了Urlmappings.groovy中的某些内容?
  • 您是否通过反向代理访问您的页面?尝试直接访问该页面(8080 或 8443)以仔细检查您的主页不只是未能呈现。我想要么页面抛出错误,要么你的反向代理有问题。
  • 我添加了我的 UrlMappings 和 Home Controller 只是为了提供更多参考

标签: grails tomcat6


【解决方案1】:

日志中有错误吗?

下一步,一个接一个地尝试(每一步都测试):

  1. "/"(controller: "home") - 删除“动作”。
  2. def index = {} 更改为def index() {}
  3. 添加“布局”:render(view:"index", layout:null)
  4. 从“index.gsp”中删除几乎所有代码。
  5. 添加 /home 进行渲染:render(view:"/home/index")
  6. render(view:"index") 替换为render text: 'test'
  7. 这个网址有效吗? http://yourip:8080/appName/home/index

这可能有助于找到问题。每次执行完都会出现 404 错误吗?

【讨论】:

    猜你喜欢
    • 2023-04-04
    • 2015-01-02
    • 2017-05-01
    • 2022-01-16
    • 1970-01-01
    • 2013-12-23
    • 1970-01-01
    • 2021-07-01
    • 1970-01-01
    相关资源
    最近更新 更多