mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-12 07:02:14 +08:00
优化重定向
This commit is contained in:
@@ -6,7 +6,10 @@ import org.springframework.stereotype.Controller;
|
|||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tanghc
|
* @author tanghc
|
||||||
@@ -18,14 +21,15 @@ public class RedirectController {
|
|||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
@RequestMapping("/{method}/{version}/")
|
@RequestMapping("/{method}/{version}/")
|
||||||
public String redirect(
|
public void redirect(
|
||||||
@PathVariable("method") String method
|
@PathVariable("method") String method
|
||||||
, @PathVariable("version") String version
|
, @PathVariable("version") String version
|
||||||
, HttpServletRequest request
|
, HttpServletRequest request
|
||||||
) {
|
, HttpServletResponse response
|
||||||
|
) throws ServletException, IOException {
|
||||||
request.setAttribute(SopConstants.REDIRECT_METHOD_KEY, method);
|
request.setAttribute(SopConstants.REDIRECT_METHOD_KEY, method);
|
||||||
request.setAttribute(SopConstants.REDIRECT_VERSION_KEY, version);
|
request.setAttribute(SopConstants.REDIRECT_VERSION_KEY, version);
|
||||||
return "forward:" + path;
|
request.getRequestDispatcher(path).forward(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user