本文整理汇总了Java中org.springframework.web.bind.ServletRequestUtils.getIntParameter方法的典型用法代码示例。如果您正苦于以下问题:Java ServletRequestUtils.getIntParameter方法的具体用法?Java ServletRequestUtils.getIntParameter怎么用?Java ServletRequestUtils.getIntParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.bind.ServletRequestUtils
的用法示例。
在下文中一共展示了ServletRequestUtils.getIntParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: history
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@RequestMapping("/job/{jobId}/history")
public ModelAndView history(@PathVariable int jobId,
HttpServletRequest request, HttpServletResponse response) {
ModelAndView mav = new ModelAndView();
int page = ServletRequestUtils.getIntParameter(request, "p", 0);
int pageSize = 20;
HistoryPage historyPage = getJobService().getHistory(jobId, page, pageSize);
PagedListHolder pagedListHolder = new PageHolder(historyPage.getTotalNumberOfResults(), page, pageSize, 10);
mav.addObject("job", getJobService().getJob(jobId));
mav.addObject("history", historyPage.getHistoryInfos());
mav.addObject("pagedListHolder", pagedListHolder);
mav.addObject("page", page);
mav.addObject("numberOfPages", historyPage.getNumberOfPages());
mav.addObject("role", getRole());
mav.setViewName("history");
return mav;
}
示例3: 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;
}
示例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: showForm
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
/**
* Displays the form to add a DataImportTool(Migration Settings)
*
* @param request
* @param model
* @return new ModelAndView
* @throws ServletRequestBindingException
*/
@RequestMapping(method = RequestMethod.GET)
public ModelAndView showForm(HttpServletRequest request, ModelMap model) throws ServletRequestBindingException{
DataImportTool dit;
Integer Id = ServletRequestUtils.getIntParameter(request, "id");
if (Id != null) {
dit = Context.getService(DataImportToolService.class).getDataImportTool();
} else {
dit = new DataImportTool();
}
model.addAttribute("dit", dit);
return new ModelAndView("/module/dataimporttool/addMigrationSettings", model);
}
开发者ID:openmrs,项目名称:openmrs-module-dataimporttool,代码行数:24,代码来源:DataImportToolStartMigrationController.java
示例6: handleRequestInternal
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@RequestMapping(method = { RequestMethod.POST, RequestMethod.GET })
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Integer channelId = ServletRequestUtils.getIntParameter(request, "channelId");
if (request.getParameter("add") != null) {
String url = StringUtils.trim(request.getParameter("add"));
podcastService.createChannel(url);
return new ModelAndView(new RedirectView("podcastChannels.view"));
}
if (request.getParameter("downloadEpisode") != null) {
download(StringUtil.parseInts(request.getParameter("downloadEpisode")));
return new ModelAndView(new RedirectView("podcastChannel.view?id=" + channelId));
}
if (request.getParameter("deleteChannel") != null) {
podcastService.deleteChannel(channelId);
return new ModelAndView(new RedirectView("podcastChannels.view"));
}
if (request.getParameter("deleteEpisode") != null) {
for (int episodeId : StringUtil.parseInts(request.getParameter("deleteEpisode"))) {
podcastService.deleteEpisode(episodeId, true);
}
return new ModelAndView(new RedirectView("podcastChannel.view?id=" + channelId));
}
if (request.getParameter("refresh") != null) {
if (channelId != null) {
podcastService.refreshChannel(channelId, true);
return new ModelAndView(new RedirectView("podcastChannel.view?id=" + channelId));
} else {
podcastService.refreshAllChannels(true);
return new ModelAndView(new RedirectView("podcastChannels.view"));
}
}
return new ModelAndView(new RedirectView("podcastChannels.view"));
}
示例7: handleRequest
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@RequestMapping(method = RequestMethod.GET)
public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
response.setHeader("Access-Control-Allow-Origin", "*");
int id = ServletRequestUtils.getIntParameter(request, "id");
MediaFile mediaFile = mediaFileService.getMediaFile(id);
Player player = playerService.getPlayer(request, response);
String username = player.getUsername();
if (mediaFile == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "Media file not found: " + id);
return;
}
if (username != null && !securityService.isFolderAccessAllowed(mediaFile, username)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN,
"Access to file " + mediaFile.getId() + " is forbidden for user " + username);
return;
}
Integer duration = mediaFile.getDurationSeconds();
if (duration == null || duration == 0) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unknown duration for media file: " + id);
return;
}
response.setContentType("application/vnd.apple.mpegurl");
response.setCharacterEncoding(StringUtil.ENCODING_UTF8);
List<Pair<Integer, Dimension>> bitRates = parseBitRates(request);
PrintWriter writer = response.getWriter();
if (bitRates.size() > 1) {
generateVariantPlaylist(request, id, player, bitRates, writer);
} else {
generateNormalPlaylist(request, id, player, bitRates.size() == 1 ? bitRates.get(0) : null, duration, writer);
}
return;
}
示例8: handleRequest
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@RequestMapping(method = RequestMethod.GET)
public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
CoverArtRequest coverArtRequest = createCoverArtRequest(request);
LOG.trace("handleRequest - " + coverArtRequest);
Integer size = ServletRequestUtils.getIntParameter(request, "size");
// Send fallback image if no ID is given. (No need to cache it, since it will be cached in browser.)
if (coverArtRequest == null) {
sendFallback(size, response);
return;
}
try {
// Optimize if no scaling is required.
if (size == null && coverArtRequest.getCoverArt() != null) {
LOG.trace("sendUnscaled - " + coverArtRequest);
sendUnscaled(coverArtRequest, response);
return;
}
// Send cached image, creating it if necessary.
if (size == null) {
size = CoverArtScheme.LARGE.getSize() * 2;
}
File cachedImage = getCachedImage(coverArtRequest, size);
sendImage(cachedImage, response);
} catch (Exception e) {
LOG.debug("Sending fallback as an exception was encountered during normal cover art processing", e);
sendFallback(size, response);
}
}
示例9: createMediaFileCoverArtRequest
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
private CoverArtRequest createMediaFileCoverArtRequest(int id, HttpServletRequest request) {
MediaFile mediaFile = mediaFileService.getMediaFile(id);
if (mediaFile == null) {
return null;
}
if (mediaFile.isVideo()) {
int offset = ServletRequestUtils.getIntParameter(request, "offset", 60);
return new VideoCoverArtRequest(mediaFile, offset);
}
return new MediaFileCoverArtRequest(mediaFile);
}
示例10: handleRequest
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@RequestMapping(method = RequestMethod.GET)
public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
User user = securityService.getCurrentUser(request);
TransferStatus status = null;
try {
status = statusService.createDownloadStatus(playerService.getPlayer(request, response, false, false));
MediaFile mediaFile = getMediaFile(request);
Integer playlistId = ServletRequestUtils.getIntParameter(request, "playlist");
String playerId = request.getParameter("player");
int[] indexes = request.getParameter("i") == null ? null : ServletRequestUtils.getIntParameters(request, "i");
if (mediaFile != null) {
response.setIntHeader("ETag", mediaFile.getId());
response.setHeader("Accept-Ranges", "bytes");
}
HttpRange range = HttpRange.valueOf(request.getHeader("Range"));
if (range != null) {
response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
LOG.info("Got HTTP range: " + range);
}
if (mediaFile != null) {
if (!securityService.isFolderAccessAllowed(mediaFile, user.getUsername())) {
response.sendError(HttpServletResponse.SC_FORBIDDEN,
"Access to file " + mediaFile.getId() + " is forbidden for user " + user.getUsername());
return;
}
if (mediaFile.isFile()) {
downloadFile(response, status, mediaFile.getFile(), range);
} else {
List<MediaFile> children = mediaFileService.getChildrenOf(mediaFile, true, false, true);
String zipFileName = FilenameUtils.getBaseName(mediaFile.getPath()) + ".zip";
File coverArtFile = indexes == null ? mediaFile.getCoverArtFile() : null;
downloadFiles(response, status, children, indexes, coverArtFile, range, zipFileName);
}
} else if (playlistId != null) {
List<MediaFile> songs = playlistService.getFilesInPlaylist(playlistId);
Playlist playlist = playlistService.getPlaylist(playlistId);
downloadFiles(response, status, songs, null, null, range, playlist.getName() + ".zip");
} else if (playerId != null) {
Player player = playerService.getPlayerById(playerId);
PlayQueue playQueue = player.getPlayQueue();
playQueue.setName("Playlist");
downloadFiles(response, status, playQueue.getFiles(), indexes, null, range, "download.zip");
}
} finally {
if (status != null) {
statusService.removeDownloadStatus(status);
securityService.updateUserByteCounts(user, 0L, status.getBytesTransfered(), 0L);
}
}
}
示例11: getUser
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
private User getUser(HttpServletRequest request) throws ServletRequestBindingException {
Integer userIndex = ServletRequestUtils.getIntParameter(request, "userIndex");
if (userIndex != null) {
List<User> allUsers = securityService.getAllUsers();
if (userIndex >= 0 && userIndex < allUsers.size()) {
return allUsers.get(userIndex);
}
}
return null;
}
示例12: getSingleFile
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
private MediaFile getSingleFile(HttpServletRequest request) throws ServletRequestBindingException {
String path = request.getParameter("path");
if (path != null) {
return mediaFileService.getMediaFile(path);
}
Integer id = ServletRequestUtils.getIntParameter(request, "id");
if (id != null) {
return mediaFileService.getMediaFile(id);
}
return null;
}
示例13: handleRequestInternal
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request) throws Exception {
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
Integer rating = ServletRequestUtils.getIntParameter(request, "rating");
if (rating == 0) {
rating = null;
}
MediaFile mediaFile = mediaFileService.getMediaFile(id);
String username = securityService.getCurrentUsername(request);
ratingService.setRatingForUser(username, mediaFile, rating);
return new ModelAndView(new RedirectView("main.view?id=" + id));
}
示例14: getMediaFiles
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
private List<MediaFile> getMediaFiles(HttpServletRequest request) throws Exception {
Integer id = ServletRequestUtils.getIntParameter(request, "id");
String playerId = request.getParameter("player");
Integer playlistId = ServletRequestUtils.getIntParameter(request, "playlist");
List<MediaFile> result = new ArrayList<>();
if (id != null) {
MediaFile album = mediaFileService.getMediaFile(id);
int[] indexes = ServletRequestUtils.getIntParameters(request, "i");
if (indexes.length == 0) {
return Arrays.asList(album);
}
List<MediaFile> children = mediaFileService.getChildrenOf(album, true, false, true);
for (int index : indexes) {
result.add(children.get(index));
}
}
else if (playerId != null) {
Player player = playerService.getPlayerById(playerId);
PlayQueue playQueue = player.getPlayQueue();
result = playQueue.getFiles();
}
else if (playlistId != null) {
result = playlistService.getFilesInPlaylist(playlistId);
}
return result;
}
示例15: preHandle
import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
/**
* This is not a good practice to use sysout. Always integrate any logger
* with your application. We will discuss about integrating logger with
* spring boot application in some later article
*/
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object object) throws Exception {
log.info("In preHandle we are Intercepting the Request");
String requestURI = request.getRequestURI();
Integer personId = ServletRequestUtils.getIntParameter(request, "personId", 0);
log.info("RequestURI::" + requestURI +
" || Search for Person with personId ::" + personId);
return true;
}