Created
June 5, 2016 13:18
-
-
Save ScienJus/2fc2edca912977623939d4310000bb5b to your computer and use it in GitHub Desktop.
redirect by handler mapping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.scienjus; | |
import org.springframework.web.method.HandlerMethod; | |
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; | |
import javax.servlet.http.HttpServletRequest; | |
/** | |
* @author ScienJus | |
* @date 16/6/5. | |
*/ | |
public class ApiHandlerMapping extends RequestMappingHandlerMapping { | |
private static final String API_PREFIX = "/api/"; | |
@Override | |
protected HandlerMethod lookupHandlerMethod(String lookupPath, HttpServletRequest request) throws Exception { | |
if (lookupPath.startsWith(API_PREFIX)) { | |
lookupPath = lookupPath.substring(API_PREFIX.length() - 1); | |
} | |
return super.lookupHandlerMethod(lookupPath, request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment