本文整理汇总了Java中org.springframework.web.bind.ServletRequestUtils类的典型用法代码示例。如果您正苦于以下问题:Java ServletRequestUtils类的具体用法?Java ServletRequestUtils怎么用?Java ServletRequestUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServletRequestUtils类属于org.springframework.web.bind包,在下文中一共展示了ServletRequestUtils类的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: getAlbumInfo
import org.springframework.web.bind.ServletRequestUtils; //导入依赖的package包/类
@RequestMapping(path = "/getAlbumInfo")
public void getAlbumInfo(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
MediaFile mediaFile = this.mediaFileService.getMediaFile(id);
if (mediaFile == null) {
error(request, response, SubsonicRESTController.ErrorCode.NOT_FOUND, "Media file not found.");
return;
}
AlbumNotes albumNotes = this.lastFmService.getAlbumNotes(mediaFile);
AlbumInfo result = getAlbumInfoInternal(albumNotes);
Response res = createResponse();
res.setAlbumInfo(result);
this.jaxbWriter.writeResponse(request, response, res);
}
示例3: getAlbumInfo2
import org.springframework.web.bind.ServletRequestUtils; //导入依赖的package包/类
@RequestMapping(path = "/getAlbumInfo2")
public void getAlbumInfo2(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
Album album = this.albumDao.getAlbum(id);
if (album == null) {
error(request, response, SubsonicRESTController.ErrorCode.NOT_FOUND, "Album not found.");
return;
}
AlbumNotes albumNotes = this.lastFmService.getAlbumNotes(album);
AlbumInfo result = getAlbumInfoInternal(albumNotes);
Response res = createResponse();
res.setAlbumInfo(result);
this.jaxbWriter.writeResponse(request, response, res);
}
示例4: handleRequestInternal
import org.springframework.web.bind.ServletRequestUtils; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<>();
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
User user = securityService.getCurrentUser(request);
String username = user.getUsername();
UserSettings userSettings = settingsService.getUserSettings(username);
Player player = playerService.getPlayer(request, response);
Playlist playlist = playlistService.getPlaylist(id);
if (playlist == null) {
return new ModelAndView(new RedirectView("notFound"));
}
map.put("playlist", playlist);
map.put("user", user);
map.put("player", player);
map.put("editAllowed", username.equals(playlist.getUsername()) || securityService.isAdmin(username));
map.put("partyMode", userSettings.isPartyModeEnabled());
return new ModelAndView("playlist","model",map);
}
示例5: getAvatar
import org.springframework.web.bind.ServletRequestUtils; //导入依赖的package包/类
private Avatar getAvatar(HttpServletRequest request) {
String id = request.getParameter("id");
boolean forceCustom = ServletRequestUtils.getBooleanParameter(request, "forceCustom", false);
if (id != null) {
return settingsService.getSystemAvatar(Integer.parseInt(id));
}
String username = request.getParameter("username");
if (username == null) {
return null;
}
UserSettings userSettings = settingsService.getUserSettings(username);
if (userSettings.getAvatarScheme() == AvatarScheme.CUSTOM || forceCustom) {
return settingsService.getCustomAvatar(username);
}
if(userSettings.getAvatarScheme() == AvatarScheme.NONE) {
return null;
}
return settingsService.getSystemAvatar(userSettings.getSystemAvatarId());
}
示例6: exportPlaylist
import org.springframework.web.bind.ServletRequestUtils; //导入依赖的package包/类
@RequestMapping(method = { RequestMethod.GET })
public ModelAndView exportPlaylist(HttpServletRequest request, HttpServletResponse response) throws Exception {
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
Playlist playlist = playlistService.getPlaylist(id);
if (!playlistService.isReadAllowed(playlist, securityService.getCurrentUsername(request))) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return null;
}
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment; filename=\"" + StringUtil.fileSystemSafe(playlist.getName()) + ".m3u8\"");
playlistService.exportPlaylist(id, response.getOutputStream());
return null;
}
示例7: handleRequestInternal
import org.springframework.web.bind.ServletRequestUtils; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
String artist = request.getParameter("artist");
String album = request.getParameter("album");
MediaFile dir = mediaFileService.getMediaFile(id);
if (StringUtils.isBlank(artist)) {
artist = dir.getArtist();
}
if (StringUtils.isBlank(album)) {
album = dir.getAlbumName();
}
Map<String, Object> map = new HashMap<>();
map.put("id", id);
map.put("artist", artist);
map.put("album", album);
return new ModelAndView("changeCoverArt","model",map);
}
示例8: handleRequestInternal
import org.springframework.web.bind.ServletRequestUtils; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
MediaFile dir = mediaFileService.getMediaFile(id);
List<MediaFile> files = mediaFileService.getChildrenOf(dir, true, false, true, false);
Map<String, Object> map = new HashMap<String, Object>();
if (!files.isEmpty()) {
map.put("defaultArtist", files.get(0).getArtist());
map.put("defaultAlbum", files.get(0).getAlbumName());
map.put("defaultYear", files.get(0).getYear());
map.put("defaultGenre", files.get(0).getGenre());
}
map.put("allGenres", JaudiotaggerParser.getID3V1Genres());
List<Song> songs = new ArrayList<Song>();
for (int i = 0; i < files.size(); i++) {
songs.add(createSong(files.get(i), i));
}
map.put("id", id);
map.put("songs", songs);
return new ModelAndView("editTags","model",map);
}
示例9: handleParameters
import org.springframework.web.bind.ServletRequestUtils; //导入依赖的package包/类
private void handleParameters(HttpServletRequest request) {
boolean dlnaEnabled = ServletRequestUtils.getBooleanParameter(request, "dlnaEnabled", false);
String dlnaServerName = StringUtils.trimToNull(request.getParameter("dlnaServerName"));
String dlnaBaseLANURL = StringUtils.trimToNull(request.getParameter("dlnaBaseLANURL"));
if (dlnaServerName == null) {
dlnaServerName = "Airsonic";
}
upnpService.setMediaServerEnabled(false);
settingsService.setDlnaEnabled(dlnaEnabled);
settingsService.setDlnaServerName(dlnaServerName);
settingsService.setDlnaBaseLANURL(dlnaBaseLANURL);
settingsService.save();
upnpService.setMediaServerEnabled(dlnaEnabled);
}
示例10: handleRequestInternal
import org.springframework.web.bind.ServletRequestUtils; //导入依赖的package包/类
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
User user = securityService.getCurrentUser(request);
Map<String, Object> map = new HashMap<String, Object>();
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
MediaFile file = mediaFileService.getMediaFile(id);
mediaFileService.populateStarredDate(file, user.getUsername());
Integer duration = file.getDurationSeconds();
String playerId = playerService.getPlayer(request, response).getId();
String url = NetworkService.getBaseUrl(request);
String streamUrl = url + "stream?id=" + file.getId() + "&player=" + playerId + "&format=mp4";
String coverArtUrl = url + "coverArt.view?id=" + file.getId();
map.put("video", file);
map.put("streamUrl", streamUrl);
map.put("remoteStreamUrl", streamUrl);
map.put("remoteCoverArtUrl", coverArtUrl);
map.put("duration", duration);
map.put("bitRates", BIT_RATES);
map.put("defaultBitRate", DEFAULT_BIT_RATE);
map.put("user", user);
return new ModelAndView("videoPlayer", "model", map);
}
示例11: createVideoTranscodingSettings
import org.springframework.web.bind.ServletRequestUtils; //导入依赖的package包/类
private VideoTranscodingSettings createVideoTranscodingSettings(MediaFile file, HttpServletRequest request) throws ServletRequestBindingException {
Integer existingWidth = file.getWidth();
Integer existingHeight = file.getHeight();
Integer maxBitRate = ServletRequestUtils.getIntParameter(request, "maxBitRate");
int timeOffset = ServletRequestUtils.getIntParameter(request, "timeOffset", 0);
int defaultDuration = file.getDurationSeconds() == null ? Integer.MAX_VALUE : file.getDurationSeconds() - timeOffset;
int duration = ServletRequestUtils.getIntParameter(request, "duration", defaultDuration);
boolean hls = ServletRequestUtils.getBooleanParameter(request, "hls", false);
Dimension dim = getRequestedVideoSize(request.getParameter("size"));
if (dim == null) {
dim = getSuitableVideoSize(existingWidth, existingHeight, maxBitRate);
}
return new VideoTranscodingSettings(dim.width, dim.height, timeOffset, duration, hls);
}
示例12: handleParameters
import org.springframework.web.bind.ServletRequestUtils; //导入依赖的package包/类
private void handleParameters(HttpServletRequest request) {
boolean sonosEnabled = ServletRequestUtils.getBooleanParameter(request, "sonosEnabled", false);
String sonosServiceName = StringUtils.trimToNull(request.getParameter("sonosServiceName"));
if (sonosServiceName == null) {
sonosServiceName = "Airsonic";
}
settingsService.setSonosEnabled(sonosEnabled);
settingsService.setSonosServiceName(sonosServiceName);
settingsService.save();
sonosService.setMusicServiceEnabled(false, NetworkService.getBaseUrl(request));
sonosService.setMusicServiceEnabled(sonosEnabled, NetworkService.getBaseUrl(request));
}
示例13: 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);
}
示例14: 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);
}
示例15: render
import org.springframework.web.bind.ServletRequestUtils; //导入依赖的package包/类
@Override
public boolean render(RenderHandler handler) throws RuntimeException, IOException {
ServletRequest request = handler.getRequest();
// request 获取参数
int pn = ServletRequestUtils.getIntParameter(request, "pn", 1);
// 标签中获取参数
long uid = handler.getIntParameter(0);
String alias = handler.getStringParameter(1);
Paging paging = wrapPaing(pn);
Paging result = postPlanet.pagingByAuthorId(paging, uid, EnumPrivacy.OPEN);
handler.put(alias, result);
handler.doRender();
postRender(handler.getContext());
return true;
}