优化参数绑定

This commit is contained in:
tanghc
2019-07-26 12:20:46 +08:00
parent c40ff46da1
commit a863c00d3f
6 changed files with 108 additions and 33 deletions

View File

@@ -1,6 +1,8 @@
package com.gitee.sop.gateway.controller;
import com.gitee.sop.gatewaycommon.bean.SopConstants;
import com.gitee.sop.gatewaycommon.param.ParamNames;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
@@ -29,7 +31,14 @@ public class RedirectController {
) throws ServletException, IOException {
request.setAttribute(SopConstants.REDIRECT_METHOD_KEY, method);
request.setAttribute(SopConstants.REDIRECT_VERSION_KEY, version);
request.getRequestDispatcher(path).forward(request, response);
String queryString = request.getQueryString();
String versionQuery = ParamNames.VERSION_NAME + '=' + version;
if (StringUtils.isBlank(queryString)) {
queryString = versionQuery;
} else {
queryString = queryString + '&' + versionQuery;
}
request.getRequestDispatcher(path + '?' + queryString).forward(request, response);
}
}