【发布时间】:2011-06-29 13:22:33
【问题描述】:
我正在使用 Grails 1.3.6。我有这个文件...
grails-app/views/home/design/index.gsp
这是我的 HomeController 中定义的内容。可悲的是,每当我访问“http://localhost:port/context-path/design/”时,我都会收到 404 错误。服务器正常启动,日志中没有错误。我可以做些什么来获取我的页面而不是 404?
def index = {
def folder = params.folder;
def page = params.page;
if (page) {
try {
def contents = IOService.getFileContents(folder, page)
response.setContentType("application/json")
response << contents
} catch (FileNotFoundException e) {
response.status = 404;
} // try
} else {
render(view: "/home/${folder}/index")
} // if
}
我的 URLMappings 文件包含...
static mappings = {
"/$folder?/$page"{
controller = "home"
action = "index"
}
"/"(view:"/index")
"500"(view:'/error')
}
谢谢,- 戴夫
【问题讨论】:
-
您是要访问
/context-path/home/design吗? (对于您当前的课程,这仍然是 404,但会使您的示例排列得更好)
标签: grails