Results 1 to 5 of 5

Thread: How to change the base-url of all scaffolded views?

  1. #1
    Join Date
    Jul 2011
    Posts
    26

    Default How to change the base-url of all scaffolded views?

    I want to use the scaffolded views as my admin interface and therefore point all of them to /admin/ instead of / .

    How can I do this?

  2. #2
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    667

    Lightbulb

    The "web mvc scaffold" command that creates the controller and views for a single entity has an optional "path" argument that lets you specify the base URL for that entity (defaults to e.g. "person" for the Person entity). So you could set this to "admin/foo" when scaffolding the UI for the Foo entity.

    The "web mvc all" command that creates the controller and views for the whole application at once has no such option, as it's intended for a simpler use case.

    If you have existing controllers and views and want to rebase your application's URLs, I'm afraid you'll have to update them all manually.
    Andrew Swan
    "Now is the EJB of our discontent made glorious Spring"

  3. #3
    Join Date
    Jul 2011
    Posts
    26

    Default

    Thanks Andrew,

    I'll create a new entity, do web mvc scaffold with path to it to see where I need to change my existing classes.

    How do I change the directory of the index-page to /admin/ as well?

  4. #4
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    667

    Lightbulb

    Quote Originally Posted by Alimdoener View Post
    How do I change the directory of the index-page to /admin/ as well?
    In your webmvc-config.xml, add this element alongside the others of this type (or edit the existing one that points to this view name):
    Code:
    <mvc:view-controller path="/admin" view-name="index"/>

  5. #5
    Join Date
    Jul 2011
    Posts
    26

    Default

    Thanks, it worked perfectly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •