org.springframework.web.bind.ServletRequestUtils Java Examples
The following examples show how to use
org.springframework.web.bind.ServletRequestUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SubsonicRESTController.java From airsonic with GNU General Public License v3.0 | 6 votes |
@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); }
Example #2
Source File: ExportPlayListController.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
@GetMapping 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; }
Example #3
Source File: SysLogController.java From EasyEE with MIT License | 6 votes |
/** * 分页查询 * * @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 = "logTime"; } if (!isNotNullAndEmpty(order)) { order = "desc"; } PageBean pb = super.getPageBean(); // 获得分页对象 pb.setSort(sort); pb.setSortOrder(order); sysLogService.findByPage(pb, sysLogCriteria); return super.setJsonPaginationMap(pb); }
Example #4
Source File: PlaylistController.java From subsonic with GNU General Public License v3.0 | 6 votes |
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { Map<String, Object> map = new HashMap<String, Object>(); 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.view")); } 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()); ModelAndView result = super.handleRequestInternal(request, response); result.addObject("model", map); return result; }
Example #5
Source File: SubsonicRESTController.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
@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); }
Example #6
Source File: SubsonicRESTController.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
@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); }
Example #7
Source File: SonosHelper.java From subsonic with GNU General Public License v3.0 | 6 votes |
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(); }
Example #8
Source File: ChangeCoverArtController.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
@GetMapping 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); }
Example #9
Source File: MainController.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
@GetMapping protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { Map<String, Object> map = new HashMap<>(); String username = securityService.getCurrentUsername(request); UserSettings userSettings = settingsService.getUserSettings(username); map.put("coverArtSizeMedium", CoverArtScheme.MEDIUM.getSize()); map.put("coverArtSizeLarge", CoverArtScheme.LARGE.getSize()); map.put("user", securityService.getCurrentUser(request)); map.put("visibility", userSettings.getMainVisibility()); map.put("showAlbumYear", settingsService.isSortAlbumsByYear()); map.put("showArtistInfo", userSettings.getShowArtistInfoEnabled()); map.put("partyMode", userSettings.getPartyModeEnabled()); map.put("brand", settingsService.getBrand()); map.put("viewAsList", userSettings.getViewAsList()); map.put("initialPaginationSize", userSettings.getPaginationSize()); map.put("initialPathsJSON", Util.toJson(ServletRequestUtils.getStringParameters(request, "path"))); map.put("initialIdsJSON", Util.toJson(ServletRequestUtils.getIntParameters(request, "id"))); return new ModelAndView("mediaMain", "model", map); }
Example #10
Source File: EditTagsController.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
@GetMapping 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); }
Example #11
Source File: VideoPlayerController.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
@GetMapping 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()); Double duration = file.getDuration(); Integer 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); }
Example #12
Source File: StreamController.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
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); double defaultDuration = file.getDuration() == null ? Double.MAX_VALUE : file.getDuration() - timeOffset; double duration = ServletRequestUtils.getDoubleParameter(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); }
Example #13
Source File: TeamController.java From TinyMooc with Apache License 2.0 | 6 votes |
@RequestMapping("updateDiscuss.htm") public ModelAndView updateDiscuss(HttpServletRequest req, HttpServletResponse res) { String discussId = ServletRequestUtils.getStringParameter(req, "discussId", ""); String topic = ServletRequestUtils.getStringParameter(req, "topic", ""); String content = ServletRequestUtils.getStringParameter(req, "content", ""); Discuss discuss = teamService.findById(Discuss.class, discussId); discuss.setTopic(topic); teamService.update(discuss); DetachedCriteria criteria = DetachedCriteria.forClass(ImageText.class) .createCriteria("resource") .add(Restrictions.eq("resourceObject", discussId)); List<ImageText> texts = (List<ImageText>) teamService.queryAllOfCondition(ImageText.class, criteria); ImageText text = texts.get(0); text.setContent(content); teamService.update(text); return new ModelAndView("/common/outSuccess"); }
Example #14
Source File: AdminController.java From TinyMooc with Apache License 2.0 | 6 votes |
@RequestMapping("alterLevel.htm") public ModelAndView alterLevel(HttpServletRequest req, HttpServletResponse res) { String levelId = ServletRequestUtils.getStringParameter(req, "levelId", ""); String lv1 = ServletRequestUtils.getStringParameter(req, "level", ""); int lv = Integer.parseInt(lv1); String condition1 = ServletRequestUtils.getStringParameter(req, "condition", ""); int condition = Integer.parseInt(condition1); String title = ServletRequestUtils.getStringParameter(req, "title", ""); String type = ServletRequestUtils.getStringParameter(req, "type", ""); Level level = admin.findById(Level.class, levelId); level.setLv(lv); level.setLvCondition(condition); level.setTitle(title); level.setType(type); admin.update(level); return new ModelAndView("redirect:turnToLevelManage.htm"); }
Example #15
Source File: SysLogController.java From EasyEE with MIT License | 6 votes |
/** * 分页查询 * * @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); }
Example #16
Source File: PerfController.java From oneops with Apache License 2.0 | 6 votes |
/** * 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); }
Example #17
Source File: ValidateCodeFilter.java From imooc-security with Apache License 2.0 | 6 votes |
private void validate(ServletWebRequest request) throws ServletRequestBindingException { ImageCode codeInSession = (ImageCode) sessionStrategy.getAttribute(request,ValidateCodeController.SESSION_KEY_IMAGE); String codeInRequest = ServletRequestUtils.getStringParameter(request.getRequest(), "imageCode"); if(StringUtils.isBlank(codeInRequest)){ throw new ValidateCodeException("验证码不能为空"); } if(codeInSession==null){ throw new ValidateCodeException("验证码不存在"); } if(codeInSession.isExpired()){ sessionStrategy.removeAttribute(request,ValidateCodeController.SESSION_KEY_IMAGE); throw new ValidateCodeException("验证码过期"); } if(!StringUtils.equals(codeInSession.getCode(),codeInRequest)){ throw new ValidateCodeException("验证码不匹配"); } sessionStrategy.removeAttribute(request,ValidateCodeController.SESSION_KEY_IMAGE); }
Example #18
Source File: ValidateCodeFilter.java From SpringAll with MIT License | 6 votes |
private void validateCode(ServletWebRequest servletWebRequest) throws ServletRequestBindingException { ImageCode codeInSession = (ImageCode) sessionStrategy.getAttribute(servletWebRequest, ValidateController.SESSION_KEY_IMAGE_CODE); String codeInRequest = ServletRequestUtils.getStringParameter(servletWebRequest.getRequest(), "imageCode"); if (StringUtils.isBlank(codeInRequest)) { throw new ValidateCodeException("验证码不能为空!"); } if (codeInSession == null) { throw new ValidateCodeException("验证码不存在!"); } if (codeInSession.isExpire()) { sessionStrategy.removeAttribute(servletWebRequest, ValidateController.SESSION_KEY_IMAGE_CODE); throw new ValidateCodeException("验证码已过期!"); } if (!StringUtils.equalsIgnoreCase(codeInSession.getCode(), codeInRequest)) { throw new ValidateCodeException("验证码不正确!"); } sessionStrategy.removeAttribute(servletWebRequest, ValidateController.SESSION_KEY_IMAGE_CODE); }
Example #19
Source File: SmsCodeFilter.java From SpringAll with MIT License | 6 votes |
private void validateCode(ServletWebRequest servletWebRequest) throws ServletRequestBindingException { String smsCodeInRequest = ServletRequestUtils.getStringParameter(servletWebRequest.getRequest(), "smsCode"); String mobileInRequest = ServletRequestUtils.getStringParameter(servletWebRequest.getRequest(), "smsCode"); SmsCode codeInSession = (SmsCode) sessionStrategy.getAttribute(servletWebRequest, ValidateController.SESSION_KEY_SMS_CODE + mobileInRequest); if (StringUtils.isBlank(smsCodeInRequest)) { throw new ValidateCodeException("验证码不能为空!"); } if (codeInSession == null) { throw new ValidateCodeException("验证码不存在!"); } if (codeInSession.isExpire()) { sessionStrategy.removeAttribute(servletWebRequest, ValidateController.SESSION_KEY_IMAGE_CODE); throw new ValidateCodeException("验证码已过期!"); } if (!StringUtils.equalsIgnoreCase(codeInSession.getCode(), smsCodeInRequest)) { throw new ValidateCodeException("验证码不正确!"); } sessionStrategy.removeAttribute(servletWebRequest, ValidateController.SESSION_KEY_IMAGE_CODE); }
Example #20
Source File: AvatarController.java From subsonic with GNU General Public License v3.0 | 6 votes |
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); } return settingsService.getSystemAvatar(userSettings.getSystemAvatarId()); }
Example #21
Source File: CourseController.java From TinyMooc with Apache License 2.0 | 6 votes |
@RequestMapping("startStudy.htm") public ModelAndView startStudy(HttpServletRequest req, HttpServletResponse res) { // 本课程的学习状态 String courseId = ServletRequestUtils.getStringParameter(req, "courseId", ""); User user = (User) req.getSession().getAttribute("user"); Course course = courseService.findById(Course.class, courseId); UserCourse userCourse = new UserCourse(); userCourse.setCourse(course); userCourse.setLearnState("学习中"); userCourse.setStartDate(new Date()); userCourse.setUser(user); userCourse.setUserCourseId(UUIDGenerator.randomUUID()); userCourse.setUserPosition("学员"); courseService.save(userCourse); return new ModelAndView("redirect:courseDetailPage.htm?courseId=" + courseId); }
Example #22
Source File: ValidateCodeFilter.java From SpringAll with MIT License | 6 votes |
private void validateCode(ServletWebRequest servletWebRequest) throws ServletRequestBindingException { ImageCode codeInSession = (ImageCode) sessionStrategy.getAttribute(servletWebRequest, ValidateController.SESSION_KEY_IMAGE_CODE); String codeInRequest = ServletRequestUtils.getStringParameter(servletWebRequest.getRequest(), "imageCode"); if (StringUtils.isBlank(codeInRequest)) { throw new ValidateCodeException("验证码不能为空!"); } if (codeInSession == null) { throw new ValidateCodeException("验证码不存在!"); } if (codeInSession.isExpire()) { sessionStrategy.removeAttribute(servletWebRequest, ValidateController.SESSION_KEY_IMAGE_CODE); throw new ValidateCodeException("验证码已过期!"); } if (!StringUtils.equalsIgnoreCase(codeInSession.getCode(), codeInRequest)) { throw new ValidateCodeException("验证码不正确!"); } sessionStrategy.removeAttribute(servletWebRequest, ValidateController.SESSION_KEY_IMAGE_CODE); }
Example #23
Source File: AdminController.java From TinyMooc with Apache License 2.0 | 6 votes |
@RequestMapping("addLevel.htm") public ModelAndView addLevel(HttpServletRequest req, HttpServletResponse res) throws Exception { String lv = ServletRequestUtils.getStringParameter(req, "level", ""); String title = ServletRequestUtils.getStringParameter(req, "title", ""); int level1 = Integer.parseInt(lv); String condition = ServletRequestUtils.getStringParameter(req, "condition", ""); int condition1 = Integer.parseInt(condition); String type = ServletRequestUtils.getStringParameter(req, "type", ""); Level level = new Level(); level.setLevelId(UUIDGenerator.randomUUID()); level.setTitle(title); level.setLv(level1); level.setLvCondition(condition1); level.setType(type); admin.save(level); return new ModelAndView("redirect:turnToLevelManage.htm"); }
Example #24
Source File: SmsCodeFilter.java From SpringAll with MIT License | 6 votes |
private void validateCode(ServletWebRequest servletWebRequest) throws ServletRequestBindingException { String smsCodeInRequest = ServletRequestUtils.getStringParameter(servletWebRequest.getRequest(), "smsCode"); String mobileInRequest = ServletRequestUtils.getStringParameter(servletWebRequest.getRequest(), "smsCode"); SmsCode codeInSession = (SmsCode) sessionStrategy.getAttribute(servletWebRequest, ValidateController.SESSION_KEY_SMS_CODE + mobileInRequest); if (StringUtils.isBlank(smsCodeInRequest)) { throw new ValidateCodeException("验证码不能为空!"); } if (codeInSession == null) { throw new ValidateCodeException("验证码不存在!"); } if (codeInSession.isExpire()) { sessionStrategy.removeAttribute(servletWebRequest, ValidateController.SESSION_KEY_IMAGE_CODE); throw new ValidateCodeException("验证码已过期!"); } if (!StringUtils.equalsIgnoreCase(codeInSession.getCode(), smsCodeInRequest)) { throw new ValidateCodeException("验证码不正确!"); } sessionStrategy.removeAttribute(servletWebRequest, ValidateController.SESSION_KEY_IMAGE_CODE); }
Example #25
Source File: SonosSettingsController.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
@PostMapping public ModelAndView doPost(HttpServletRequest request) throws Exception { boolean sonosEnabled = ServletRequestUtils.getBooleanParameter(request, "sonosEnabled", false); String sonosServiceName = StringUtils.trimToNull(request.getParameter("sonosServiceName")); if (StringUtils.isBlank(sonosServiceName)) { sonosServiceName = "Airsonic"; } settingsService.setSonosLinkMethod(request.getParameter("sonosLinkMethod")); settingsService.setSonosEnabled(sonosEnabled); settingsService.setSonosServiceName(sonosServiceName); settingsService.setSonosCallbackHostAddress(StringUtils.appendIfMissing(StringUtils.trimToNull(request.getParameter("callbackHostAddress")), "/")); settingsService.save(); List<String> returnCodes = sonosService.updateMusicServiceRegistration(); Map<String, Object> map = getModel(request); map.put("returnCodes", returnCodes); return new ModelAndView("sonosSettings", "model", map); }
Example #26
Source File: CourseController.java From TinyMooc with Apache License 2.0 | 5 votes |
@RequestMapping("createLessonPage.htm") public ModelAndView createLessonPage(HttpServletRequest req, HttpServletResponse res) { String courseId = ServletRequestUtils.getStringParameter(req, "courseId", ""); Course course = courseService.findById(Course.class, courseId); DetachedCriteria detachedCriteria1 = DetachedCriteria.forClass(UserCourse.class) .createCriteria("course") .add(Restrictions.eq("course", course)); List<UserCourse> userCourseList = (List<UserCourse>) courseService.queryAllOfCondition(UserCourse.class, detachedCriteria1); int lessons = userCourseList.size(); req.setAttribute("course", course); req.setAttribute("lessons", lessons); return new ModelAndView("/course/createLesson"); }
Example #27
Source File: AbstractAuditDataHandlerController.java From Asqatasun with GNU Affero General Public License v3.0 | 5 votes |
/** * * @param audit * @param model * @param httpStatusCode * @param request * @param returnRedirectView * @return * @throws ServletRequestBindingException */ protected String preparePageListStatsByHttpStatusCode( Audit audit, Model model, HttpStatusCodeFamily httpStatusCode, HttpServletRequest request, boolean returnRedirectView) throws ServletRequestBindingException { String invalidTest = ServletRequestUtils.getStringParameter(request, TgolPaginatedListFactory.INVALID_TEST_PARAM); if (invalidTest != null && !this.invalidTestValueCheckerPattern.matcher(invalidTest).matches()) { throw new ForbiddenPageException(); } PaginatedList paginatedList = TgolPaginatedListFactory.getInstance().getPaginatedList( httpStatusCode, ServletRequestUtils.getStringParameter(request, TgolPaginatedListFactory.PAGE_SIZE_PARAM), ServletRequestUtils.getStringParameter(request, TgolPaginatedListFactory.SORT_DIRECTION_PARAM), ServletRequestUtils.getStringParameter(request, TgolPaginatedListFactory.SORT_CRITERION_PARAM), ServletRequestUtils.getStringParameter(request, TgolPaginatedListFactory.PAGE_PARAM), ServletRequestUtils.getStringParameter(request, TgolPaginatedListFactory.SORT_CONTAINING_URL_PARAM), invalidTest, authorizedPageSize, authorizedSortCriterion, audit.getId()); model.addAttribute(TgolKeyStore.PAGE_LIST_KEY, paginatedList); model.addAttribute(TgolKeyStore.AUTHORIZED_PAGE_SIZE_KEY, authorizedPageSize); model.addAttribute(TgolKeyStore.AUTHORIZED_SORT_CRITERION_KEY, authorizedSortCriterion); setFromToValues(paginatedList, model); // don't forge to add audit statistics to model // addAuditStatisticsToModel(audit, model, TgolKeyStore.TEST_DISPLAY_SCOPE_VALUE); return (returnRedirectView) ? TgolKeyStore.PAGE_LIST_XXX_VIEW_REDIRECT_NAME : TgolKeyStore.PAGE_LIST_XXX_VIEW_NAME; }
Example #28
Source File: TeamController.java From TinyMooc with Apache License 2.0 | 5 votes |
@RequestMapping("addApplyUser.htm") public ModelAndView addApplyUser(HttpServletRequest req, HttpServletResponse res) { String userTeamId = ServletRequestUtils.getStringParameter(req, "userTeamId", ""); UserTeam userTeam = teamService.findById(UserTeam.class, userTeamId); String teamId = userTeam.getTeam().getTeamId(); userTeam.setUserState("批准"); userTeam.setApproveDate(new Date()); userTeam.setContribution(0); userTeam.setUserPosition("组员"); teamService.update(userTeam); return new ModelAndView("redirect:membersAdminPage.htm?teamId=" + teamId); }
Example #29
Source File: BaseController.java From EasyEE with MIT License | 5 votes |
/** * 获得分页对象,自动封装客户端提交的分页参数 * * @return */ @SuppressWarnings("rawtypes") public PageBean getPageBean() { PageBean pb = new PageBean(); /* * EasyUI Pagination parameter EasyUI Sort parameter */ int page = ServletRequestUtils.getIntParameter(request, "page", 1); int rows = ServletRequestUtils.getIntParameter(request, "rows", 10); String sort = ServletRequestUtils.getStringParameter(request, "sort", ""); String order = ServletRequestUtils.getStringParameter(request, "order", ""); pb.setPageNo(page); pb.setRowsPerPage(rows); // 分页排序 // 防止SQL注入过滤 sort = StringUtils.filterSQLCondition(sort); // 防止SQL注入过滤 order = StringUtils.filterSQLCondition(order); if (isNotNullAndEmpty(sort)) { pb.setSort(sort); } if (isNotNullAndEmpty(order)) { pb.setSortOrder(order); } return pb; }
Example #30
Source File: DLNASettingsController.java From subsonic with GNU General Public License v3.0 | 5 votes |
private void handleParameters(HttpServletRequest request) { boolean dlnaEnabled = ServletRequestUtils.getBooleanParameter(request, "dlnaEnabled", false); String dlnaServerName = StringUtils.trimToNull(request.getParameter("dlnaServerName")); if (dlnaServerName == null) { dlnaServerName = "Subsonic"; } upnpService.setMediaServerEnabled(false); settingsService.setDlnaEnabled(dlnaEnabled); settingsService.setDlnaServerName(dlnaServerName); settingsService.save(); upnpService.setMediaServerEnabled(dlnaEnabled); }