开发者

How to map the url's of view's in browser to one specific name?

M new to grails n now my problem is,

I want when i browse my application instead of getting URL as http://localhost:8080/merchant/ i want to display only ://localhost.

Like wise when i browse other views of my application i get URL like http://localhost:8080/merchant/register/list now also i don want it to display app controller and action names there instead i want it to display a single word may be list or something else which i want.

I gone through URLMapping concepts but i din get what exactly to do..I know i should study understand and then ask if any doubt but i don have much time..So please can any one tell me what exactly need to do.

Advance 开发者_运维百科thanks,


actually if you don't have a port in the url it takes the port 80 as default. apache http servers are running on this port normally.

there are two different ways to achieve this for a grails application running on a tomcat server.

  • change the port of the tomcat server (use the Dserver.port parameter when you start grails)
grails -Dserver.port=80 run-app
  • Or use a apache http server as proxy for your tomcat server.

http://www.unidata.ucar.edu/projects/THREDDS/tech/tds4.1/reference/TomcatBehindProxyServer.html


EDIT:

For the second thing with url's. If I get your question right, you want the list view as your default view. To achieve this, use the following URL Mapping (did not test it though):

static mappings = {
    "/$controller" {
       controller = "controller"
       action = "list"
    }
}

EDIT 2:

You only want to see the action and not the controller name.

  • this is only possible for one controller. otherwise how would grails know which action of which controller to use.

  • you can define your actions which should be accessible without the controller name in the url in your home controller.

    1. make a home controller

    2. set the following mapping

"/$action"
 {
    controller = "yourController"
    action = "action"
 }

please be aware this way all index actions on other controllers ex. /controller will not work right, as it expects you have an action with the name controller in your home controller.


EDIT 3: You can also define an url mapping for every action you want to be accessible without controller name in the url. this way the action has not to be in your home controller.

ex

"/myAction"
 {
    controller = "yourController"
    action = "myAction"
 }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜