Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012 astamuse company,Ltd.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *     http://www.apache.org/licenses/LICENSE-2.0
   * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * 
  */
 
 package com.astamuse.asta4d.sample;
 
 import static com.astamuse.asta4d.web.dispatch.HttpMethod.GET;
 import static com.astamuse.asta4d.web.dispatch.HttpMethod.POST;
 import static com.astamuse.asta4d.web.dispatch.HttpMethod.PUT;
 
 
 public class UrlRules implements UrlMappingRuleInitializer {
 
     @Override
     public void initUrlMappingRules(UrlMappingRuleHelper rules) {
         //@formatter:off
         rules.add("/")
              .redirect("/app/index");
         
         rules.add("/redirect-to-index")
         .redirect("p:/app/index");
         
         initSampleRules(rules);
         //@formatter:on
     }
 
     private void initSampleRules(UrlMappingRuleHelper rules) {
         //@formatter:off
         
         rules.add("/js/**/*").handler(new StaticResourceHandler());
         
         rules.add("/app/""/templates/index.html");
         rules.add("/app/index""/templates/index.html");
 
         rules.add("/app/snippet""/templates/snippet.html");
         
         // @ShowCode:showVariableinjectionStart
         rules.add("/app/{name}/{age}""/templates/variableinjection.html").priority(1);
         // @ShowCode:showVariableinjectionEnd
         
         rules.add("/app/attributevalues""/templates/attributevalues.html");
 
         rules.add("/app/extend/appendchild""/templates/extend/appendchild.html");
         rules.add("/app/extend/insertchild""/templates/extend/insertchild.html");
         rules.add("/app/extend/overridechild""/templates/extend/overridechild.html");
 
         rules.add("/app/embed/main""/templates/embed/main.html");
 
         rules.add("/app/ajax/getUserList").handler(GetUserListHandler.class).json();
         
         rules.add("/app/ajax/addUser").handler(AddUserHandler.class).rest();
         
         rules.add("/app/""/templates/index.html");
 
         // @ShowCode:showSuccessStart
         rules.add("/app/handler")
              .handler(LoginHandler.class)
              .handler(EchoHandler.class)
              .forward(LoginFailure.class"/templates/error.html")
              .forward("/templates/success.html");
         // @ShowCode:showSuccessEnd
         
 
         rules.add("/app/renderertypes""/templates/renderertypes.html");
         rules.add("/app/passvariables""/templates/passvariables.html");
         rules.add("/app/dynamicsnippet""/templates/dynamicsnippet.html");
 
         rules.add("/app/contextdata""/templates/contextdata.html");
 
         rules.add("/app/form/input""/templates/form/input.html");
         rules.add("/app/form/confirm").handler(FormValidateHandler.class);
         rules.add("/app/form/complete").handler(FormCompleteHandler.class);
 
         rules.add("/app/localize""/templates/localize.html");
         //@formatter:on
     }
New to GrepCode? Check out our FAQ X