本文整理汇总了Java中org.springframework.web.bind.ServletRequestUtils.getStringParameter方法的典型用法代码示例。如果您正苦于以下问题:Java ServletRequestUtils.getStringParameter方法的具体用法?Java ServletRequestUtils.getStringParameter怎么用?Java ServletRequestUtils.getStringParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.bind.ServletRequestUtils
的用法示例。
在下文中一共展示了ServletRequestUtils.getStringParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setChart
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
/**
* Sets the chart.
*
* @param request the request
* @param response the response
* @throws Exception the exception
*/
@RequestMapping("/setChart")
public void setChart(HttpServletRequest request, HttpServletResponse response) throws Exception {
String chartSetJson = ServletRequestUtils.getStringParameter(request, "chartSet");
Chart[] reqs = gson.fromJson(chartSetJson, Chart[].class);
long startTime = System.currentTimeMillis();
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < reqs.length; i++) {
Chart chart = reqs[i];
if (i > 0) {
stringBuilder.append(",");
}
stringBuilder.append("\"ok\"");
perfDao.setChart(chart);
}
stringBuilder.append("]");
long endTime = System.currentTimeMillis();
long duration = endTime - startTime;
logger.debug(request.getRemoteAddr() + " took " + duration + " ms");
response.getOutputStream().print(stringBuilder.toString());
response.setStatus(200);
}
示例2: getPerfData
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
/**
* Gets the perf data.
*
* @param request the request, contains json array of {@link PerfDataRequest}
* @param response the response, contains json array of tabled results.
* @return the perf data
* @throws Exception the exception
*/
@RequestMapping(value = "/getPerfData", method = {GET, POST})
public void getPerfData(HttpServletRequest request, HttpServletResponse response) throws Exception {
String reqSet = ServletRequestUtils.getStringParameter(request, "reqSet");
PerfDataRequest[] reqs = gson.fromJson(reqSet, PerfDataRequest[].class);
long startTime = System.currentTimeMillis();
StringBuilder bu = new StringBuilder("[ ");
for (int i = 0; i < reqs.length; i++) {
PerfDataRequest req = reqs[i];
if (i > 0) {
bu.append(",");
}
bu.append(perfDataAccessor.getPerfDataSeries(req));
}
bu.append("\n]");
long endTime = System.currentTimeMillis();
long duration = endTime - startTime;
logger.debug(request.getRemoteAddr() + " took " + duration + " ms");
response.getOutputStream().print(bu.toString());
response.setStatus(200);
}
示例3: getChart
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
/**
* Gets the chart data.
*
* @param request the request
* @param response the response
* @return the chart
* @throws Exception the exception
*/
@RequestMapping("/getChart")
public void getChart(HttpServletRequest request, HttpServletResponse response) throws Exception {
String chartSetJson = ServletRequestUtils.getStringParameter(request, "chartSet");
Chart[] reqs = gson.fromJson(chartSetJson, Chart[].class);
long startTime = System.currentTimeMillis();
StringBuilder der = new StringBuilder("[");
for (int i = 0; i < reqs.length; i++) {
Chart chart = reqs[i];
if (i > 0) {
der.append("[");
}
chart = perfDao.getChart(chart.getKey());
der.append(gson.toJson(chart));
}
der.append("]");
long endTime = System.currentTimeMillis();
long duration = endTime - startTime;
logger.debug(request.getRemoteAddr() + " took " + duration + " ms");
response.getOutputStream().print(der.toString());
response.setStatus(200);
}
示例4: render
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@Override
public boolean render(RenderHandler handler) throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, IOException {
ServletRequest request = handler.getRequest();
// request 获取参数
String ord = ServletRequestUtils.getStringParameter(request, "ord", Consts.order.NEWEST);
int pn = ServletRequestUtils.getIntParameter(request, "pn", 1);
// 标签中获取参数
int groupId = handler.getIntParameter(0);
String alias = handler.getStringParameter(1);
Paging paging = wrapPaing(pn);
Paging result = postPlanet.paging(paging, groupId, ord);
handler.put(alias, result);
handler.doRender();
postRender(handler.getContext());
return true;
}
示例5: send
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
public void send(HttpServletRequest request,
HttpServletResponse response) throws Exception {
String broadcast = ServletRequestUtils.getStringParameter(request,
"broadcast", "Y");
String username = ServletRequestUtils.getStringParameter(request,
"username");
String title = ServletRequestUtils.getStringParameter(request, "title");
String message = ServletRequestUtils.getStringParameter(request,
"message");
String uri = ServletRequestUtils.getStringParameter(request, "uri");
String apiKey = Config.getString("apiKey", "");
logger.debug("apiKey=" + apiKey);
// if (broadcast.equalsIgnoreCase("Y")) {
// notificationManager.sendBroadcast(apiKey, title, message, uri);
// } else {
// notificationManager.sendNotifcationToUser(apiKey, username, title,
// message, uri, true);
// }
response.getWriter().print("{\"result\":\"0\",\"description\":\"success\"}");
// ModelAndView mav = new ModelAndView();
// mav.setViewName("redirect:notification.do");
// return mav;
}
示例6: getBaseUrl
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
public String getBaseUrl(HttpServletRequest request) {
int port = settingsService.getPort();
String contextPath = settingsService.getUrlRedirectContextPath();
// Note that the server IP can be overridden by the "ip" parameter. Used when Subsonic and Sonos are
// on different networks.
String ip = settingsService.getLocalIpAddress();
if (request != null) {
ip = ServletRequestUtils.getStringParameter(request, "ip", ip);
}
// Note: Serving media and cover art with http (as opposed to https) works when using jetty and SubsonicDeployer.
StringBuilder url = new StringBuilder("http://")
.append(ip)
.append(":")
.append(port)
.append("/");
if (StringUtils.isNotEmpty(contextPath)) {
url.append(contextPath).append("/");
}
return url.toString();
}
示例7: formBackingObject
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
/**
* This is called prior to displaying a form for the first time. It tells Spring the
* form/command object to load into the request
*
* @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
*/
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
ConceptProposal cp = new ConceptProposal();
if (Context.isAuthenticated()) {
ConceptService cs = Context.getConceptService();
EncounterService es = Context.getEncounterService();
String id = ServletRequestUtils.getStringParameter(request, "encounterId");
if (id != null) {
cp.setEncounter(es.getEncounter(Integer.valueOf(id)));
}
id = ServletRequestUtils.getStringParameter(request, "obsConceptId");
if (id != null) {
cp.setObsConcept(cs.getConcept(Integer.valueOf(id)));
}
}
return cp;
}
示例8: populate
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@Override
public void populate(DefaultTableXYDataset dataset, StatsCollection statsCollection,
HttpServletRequest request) {
String seriesParam = ServletRequestUtils.getStringParameter(request, "sp", null);
for (int i = 0; i < statNames.size(); i++) {
String statName = statNames.get(i);
if (seriesParam != null) {
statName = MessageFormat.format(statName, seriesParam);
}
List<XYDataItem> stats = statsCollection.getStats(statName);
if (stats != null) {
String series =
ServletRequestUtils.getStringParameter(request, "s" + (i + 1) + "l", "series" + i);
dataset.addSeries(toSeries(series, stats));
}
}
}
示例9: populate
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@Override
public void populate(DefaultTableXYDataset dataset, StatsCollection statsCollection,
HttpServletRequest request) {
// get Connector name from the request
String connectorName = ServletRequestUtils.getStringParameter(request, "cn", null);
// type of statistic to be displayed
String statType = ServletRequestUtils.getStringParameter(request, "st", null);
// Series legend
String series1Legend = ServletRequestUtils.getStringParameter(request, "sl", "");
if (connectorName != null && statType != null) {
List<XYDataItem> stats =
statsCollection.getStats("stat.connector." + connectorName + "." + statType);
if (stats != null) {
dataset.addSeries(toSeries(series1Legend, stats));
}
}
}
示例10: list
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
/**
* 分页查询
*
* @return
* @throws Exception
*/
@SuppressWarnings("rawtypes")
@RequestMapping("list")
public Map<Object, Object> list(SysLogCriteria sysLogCriteria) throws Exception {
String sort = ServletRequestUtils.getStringParameter(request, "sort", "");
String order = ServletRequestUtils.getStringParameter(request, "order", "");
if (!isNotNullAndEmpty(sort) || sort.equals("logTime")) {
sort = "log_Time";
}
if (!isNotNullAndEmpty(order)) {
order = "desc";
}
PageBean pb = super.getPageBean(); // 获得分页对象
pb.setSort(sort);
pb.setSortOrder(order);
sysLogService.findByPage(pb, sysLogCriteria);
return super.setJsonPaginationMap(pb);
}
示例11: handleContext
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView handleContext(String contextName, Context context,
HttpServletRequest request, HttpServletResponse response) throws Exception {
String jspName = ServletRequestUtils.getStringParameter(request, "source", null);
if (jspName != null) {
String servletName =
getContainerWrapper().getTomcatContainer().getServletFileNameForJsp(context, jspName);
if (servletName != null) {
File servletFile = new File(servletName);
if (servletFile.exists()) {
Utils.sendFile(request, response, servletFile);
}
}
}
return null;
}
示例12: handleContext
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView handleContext(String contextName, Context context,
HttpServletRequest request, HttpServletResponse response) throws Exception {
String jspName = ServletRequestUtils.getStringParameter(request, "source", null);
ServletContext sctx = context.getServletContext();
ServletConfig scfg = (ServletConfig) context.findChild("jsp");
Options opt = new EmbeddedServletOptions(scfg, sctx);
String encoding = opt.getJavaEncoding();
String content = null;
if (jspName != null) {
String servletName =
getContainerWrapper().getTomcatContainer().getServletFileNameForJsp(context, jspName);
if (servletName != null) {
File servletFile = new File(servletName);
if (servletFile.exists()) {
try (FileInputStream fis = new FileInputStream(servletFile)) {
content = Utils.highlightStream(jspName, fis, "java", encoding);
}
}
}
}
return new ModelAndView(getViewName(), "content", content);
}
示例13: handleContext
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView handleContext(String contextName, Context context,
HttpServletRequest request, HttpServletResponse response) throws Exception {
boolean privileged = SecurityUtils.hasAttributeValueRole(getServletContext(), request);
boolean calcSize =
ServletRequestUtils.getBooleanParameter(request, "size", false) && privileged;
String sid = ServletRequestUtils.getStringParameter(request, "sid");
ApplicationSession appSession = ApplicationUtils
.getApplicationSession(context.getManager().findSession(sid), calcSize, true);
if (appSession != null) {
appSession.setAllowedToViewValues(privileged);
return new ModelAndView(getViewName(), "session", appSession);
}
return new ModelAndView(getViewName());
}
示例14: handleRequestInternal
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {
String cookieName = ServletRequestUtils.getStringParameter(request, "cn");
String state = ServletRequestUtils.getStringParameter(request, "state");
if (cookieName != null && state != null) {
cookieName = Functions.safeCookieName(cookieName);
// expire the cookies at the current date + 10years (roughly, nevermind leap years)
response.addHeader("Set-Cookie",
cookieName + "=" + state + "; Expires="
+ sdf.format(new Date(System.currentTimeMillis() + 315360000000L))
+ "; Secure=true; HttpOnly=true");
}
return null;
}
示例15: handleRequestInternal
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {
String threadName = ServletRequestUtils.getStringParameter(request, "thread", null);
Thread thread = null;
if (threadName != null) {
thread = Utils.getThreadByName(threadName);
}
if (thread != null) {
thread.stop();
}
String referer = request.getHeader("Referer");
String redirectUrl;
if (referer != null) {
redirectUrl = referer.replaceAll(replacePattern, "");
} else {
redirectUrl = request.getContextPath() + getViewName();
}
return new ModelAndView(new RedirectView(redirectUrl));
}