开发者

Confusion about URLMapping

I'm running Grails 1.3.6. I have this in my URLMappings.groovy file ...

static mappings = {
    "/$folder?/$page?"{
        controller = "Home"
        action = "index"
    }

    "/"(view:"/index")
    "500"(view:'/error')
}

and this is my HomeController ...

class HomeController {
def IOService

def index = {
    def folder = params.folder;
    def page = params.page;

    def contents = IOService.getFileContents(folder, page)  
    response.setContentType("application/json")
    response.text = contents
}   
}

however, when I visit my URL "/context-path/folder1/page1", I'm getting an Apache Tomcat 404 error (complaining about "/context-pa开发者_高级运维th/folder1"). I'm new to Grails but can't figure this out. How can I adjust my mappings to make this work?

Thanks, - Dave


I'm not sure if controller/action definitions are case-insensitive. I've always used lowercase names. Try changing

controller = "Home"

to

controller = 'home'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜