当前位置: 首页>>代码示例>>Java>>正文


Java ServletRequestUtils.getLongParameter方法代码示例

本文整理汇总了Java中org.springframework.web.bind.ServletRequestUtils.getLongParameter方法的典型用法代码示例。如果您正苦于以下问题:Java ServletRequestUtils.getLongParameter方法的具体用法?Java ServletRequestUtils.getLongParameter怎么用?Java ServletRequestUtils.getLongParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.bind.ServletRequestUtils的用法示例。


在下文中一共展示了ServletRequestUtils.getLongParameter方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doPost

import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected Object doPost(ApiResult apiResult, HttpServletRequest request,
        HttpServletResponse response) throws HttpRequestMethodNotSupportedException,
        ApiException {
    boolean isFollowAction = isFollowAction(request);
    Long blogId = ServletRequestUtils.getLongParameter(request, PARAM_BLOG_ID, -1);
    Long userId = ServletRequestUtils.getLongParameter(request, PARAM_USER_ID, -1);
    Long noteId = ServletRequestUtils.getLongParameter(request, PARAM_NOTE_ID, -1);
    Long discussionId = ServletRequestUtils.getLongParameter(request, PARAM_DISCUSSION_ID, -1);
    Long tag = ServletRequestUtils.getLongParameter(request, PARAM_TAG, -1);
    if (blogId == -1 && noteId == -1 && discussionId == -1 && tag == -1 && userId == -1) {
        throw new MissingRequestParameterException(new String[] { PARAM_BLOG_ID, PARAM_NOTE_ID,
                PARAM_DISCUSSION_ID, PARAM_TAG, PARAM_USER_ID }, null);
    }
    if (isFollowAction) {
        doFollow(apiResult, request, blogId, noteId, discussionId, tag, userId);
    } else {
        doUnfollow(apiResult, request, blogId, noteId, discussionId, tag, userId);
    }
    return null;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:25,代码来源:FollowApiController.java

示例2: formBackingObject

import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected Object formBackingObject(HttpServletRequest request) throws Exception {
    Long userId = ServletRequestUtils.getLongParameter(request, PARAM_USER_ID);
    User user = ServiceLocator.instance().getService(UserManagement.class)
            .findUserByUserId(userId, true);
    Collection<String> tags = new HashSet<String>();
    if (user.getTags() != null) {
        for (Tag tag : user.getTags()) {
            tags.add(tag.getName());
        }
    }
    UserProfileVO profile = ServiceLocator.instance().getService(UserProfileManagement.class)
            .findUserProfileVOByUserId(user.getId());
    Locale locale = SessionHandler.instance().getCurrentLocale(request);
    UserProfileForm userProfileForm = new UserProfileForm(profile, locale.getLanguage(),
            StringUtils.join(tags, ", "), new HashSet<String>());
    setFixedProfileFields(userId, userProfileForm);
    request.setAttribute("userId", user.getId());
    request.setAttribute("userStatus", user.getStatus());
    request.setAttribute("alias", user.getAlias());
    request.setAttribute("isClientManager", SecurityHelper.isClientManager());
    return userProfileForm;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:27,代码来源:UserManagementUserProfileController.java

示例3: getImage

import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@RequestMapping(value="/game/image", method=RequestMethod.GET, produces = "image/jpg" )
public void getImage(HttpServletRequest request,
		HttpServletResponse response) throws ServletException, IOException {
	
	long id = ServletRequestUtils.getLongParameter(request, "id", -1);
	byte[] imageArray = null;

	if (id > 0) {
		imageArray = imageService.getImageById(id);
	}
	
	
	if (imageArray != null)
	{
		response.getOutputStream().write(imageArray);
	}
}
 
开发者ID:kenfrank,项目名称:trivolous,代码行数:18,代码来源:GameController.java

示例4: load

import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@Override
@RequestMapping(value = "/load")
public String load(HttpServletRequest request, HttpServletResponse response) {

	Nsort nsort = new Nsort();
	long sortId = ServletRequestUtils.getLongParameter(request, "sortId", -1);
	if (sortId != -1) {
		nsort.setSortId(sortId);
	}
	long parentNsortId = ServletRequestUtils.getLongParameter(request, "parentNsortId", -1);
	if (parentNsortId != -1) {
		nsort.setParentNsortId(parentNsortId);
	}

	request.setAttribute("nsort", nsort);

	return PathResolver.getPath(request, response, BackPage.NSORT_EDIT_PAGE);
}
 
开发者ID:8090boy,项目名称:gomall.la,代码行数:19,代码来源:NsortAdminController.java

示例5: list

import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@RequestMapping("/list")
public String list(Integer pn, String title, ModelMap model, HttpServletRequest request) {
	long id = ServletRequestUtils.getLongParameter(request, "id", Const.ZERO);
	int group = ServletRequestUtils.getIntParameter(request, "group", Const.ZERO);

	Paging page = wrapPage(pn);

	postService.paging4Admin(page, id, title, group);
	model.put("page", page);
	model.put("title", title);
	model.put("id", id);
	model.put("group", group);
	return "/admin/posts/list";
}
 
开发者ID:ThomasYangZi,项目名称:mblog,代码行数:15,代码来源:PostsController.java

示例6: post

import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@RequestMapping("/submit")
public @ResponseBody Data post(Long toId, String text, HttpServletRequest request) {
	Data data = Data.failure("操作失败");
	
	long pid = ServletRequestUtils.getLongParameter(request, "pid", 0);
	
	if (!SecurityUtils.getSubject().isAuthenticated()) {
		data = Data.failure("请先登录在进行操作");
		
		return data;
	}
	if (toId > 0 && StringUtils.isNotEmpty(text)) {
		UserProfile up = getSubject().getProfile();
		
		Comment c = new Comment();
		c.setToId(toId);
		c.setContent(HtmlUtils.htmlEscape(text));
		c.setAuthorId(up.getId());
		
		c.setPid(pid);
		
		commentService.post(c);

           if(toId != up.getId()) {
		    sendNotify(up.getId(), toId, pid);
           }
		
		data = Data.success("发表成功!", Data.NOOP);
	}
	return data;
}
 
开发者ID:ThomasYangZi,项目名称:mblog,代码行数:32,代码来源:CommentController.java

示例7: handleOnSubmit

import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected ModelAndView handleOnSubmit(HttpServletRequest request, HttpServletResponse response,
        Object command, BindException errors) throws Exception {
    UserProfileForm form = (UserProfileForm) command;
    Long userId = ServletRequestUtils.getLongParameter(request, PARAM_USER_ID);
    if (userId != null) {
        return doUpdateProfile(request, response, form, errors, userId);
    }
    return null;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:14,代码来源:UserManagementUserProfileController.java

示例8: setInitialFilters

import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
/**
 * Extracts some initial filters from the request and stores them in a JSON object for use in
 * the user management view.
 *
 * @param request
 *            the request
 */
private void setInitialFilters(HttpServletRequest request) {
    Long userId = ServletRequestUtils.getLongParameter(request,
            ClientUserManagementController.PARAM_USER_ID, -1L);
    UserProfileDetails details = null;
    if (userId != -1) {
        details = ServiceLocator.findService(UserProfileManagement.class)
                .getUserProfileDetailsById(userId, false);
    }
    JsonNode filters = buildInitialFiltersJson(details);
    request.setAttribute(InitialFiltersViewController.KEY_INITIAL_FILTERS_JSON,
            JsonHelper.writeJsonTreeAsString(filters));

    ClientConfigurationProperties properties = CommunoteRuntime.getInstance()
            .getConfigurationManager().getClientConfigurationProperties();
    String primaryExternalAuthentication = properties.getPrimaryExternalAuthentication();
    boolean isDBAuthenticationAllowed = primaryExternalAuthentication == null
            || properties.getProperty(ClientPropertySecurity.ALLOW_DB_AUTH_ON_EXTERNAL,
                    ClientPropertySecurity.DEFAULT_ALLOW_DB_AUTH_ON_EXTERNAL);
    List<String> invitationProviders = new ArrayList<String>();
    if (primaryExternalAuthentication != null) {
        invitationProviders.add(primaryExternalAuthentication);
    }
    if (isDBAuthenticationAllowed) {
        invitationProviders.add(ConfigurationManagement.DEFAULT_DATABASE_ID);
    }
    request.setAttribute("invitationProviders", invitationProviders);

}
 
开发者ID:Communote,项目名称:communote-server,代码行数:36,代码来源:ClientUserManagementViewController.java

示例9: handleCreateModifyNote

import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
/**
 * Creates or edits a note or reply.
 *
 * @param apiResult
 *            the API result
 * @param request
 *            the request
 * @return a JSON object string describing the result. The object contains an optional warning
 *         message, the version of the note and the noteId.
 * @throws ApiException
 *             in case note creation failed
 */
private Object handleCreateModifyNote(ApiResult apiResult, HttpServletRequest request)
        throws ApiException {
    Long targetBlog = ParameterHelper.getParameterAsLong(request.getParameterMap(),
            "targetBlogId");
    if (targetBlog == null) {
        throw new ApiException(MessageHelper.getText(request, "error.blogpost.blog.not.set"));
    }
    Long version = ServletRequestUtils.getLongParameter(request, "version", 0L);
    Locale locale = SessionHandler.instance().getCurrentLocale(request);
    String tags = extractTags(request);
    Set<String> crossPostBlogAliasesSet = ParameterHelper.getParameterAsStringSet(
            request.getParameterMap(), "crossPostBlogAliases", ",");
    Set<String> notifyUserAliases = ParameterHelper.getParameterAsStringSet(
            request.getParameterMap(), "usersToNotify", ",");
    Long[] attachmentIds = ParameterHelper.getParameterAsLongArray(request.getParameterMap(),
            "attachmentIds");
    Long parentNoteId = ParameterHelper.getParameterAsLong(request.getParameterMap(),
            "parentPostId");
    Long noteId = ParameterHelper.getParameterAsLong(request.getParameterMap(), "postId");
    Long autosaveNoteId = ParameterHelper.getParameterAsLong(request.getParameterMap(),
            "autosaveNoteId");
    boolean publish = ParameterHelper.getParameterAsBoolean(request.getParameterMap(),
            "publish", true);

    NoteContentType contentType = extractContentType(request);
    String postText = request.getParameter("postText");
    checkNoteLength(request, postText, contentType);

    NoteStoringTO noteStoringTO = new NoteStoringTO();
    noteStoringTO.setCreationSource(this.creationSource);
    CreateBlogPostHelper.setDefaultFailLevel(noteStoringTO);
    noteStoringTO.setPublish(publish);
    noteStoringTO.setAutosaveNoteId(autosaveNoteId);
    noteStoringTO.setVersion(version);
    noteStoringTO.setContent(postText);
    noteStoringTO.setContentType(contentType);
    noteStoringTO.setBlogId(targetBlog);
    noteStoringTO.setUnparsedTags(tags);
    noteStoringTO.setUsersToNotify(notifyUserAliases);
    noteStoringTO.setAttachmentIds(attachmentIds);
    noteStoringTO.setCreatorId(SecurityHelper.getCurrentUserId());
    noteStoringTO.setSendNotifications(true);
    noteStoringTO.setIsDirectMessage(ServletRequestUtils.getBooleanParameter(request,
            "isDirectMessage", false));

    noteStoringTO.setLanguage(locale.getLanguage());

    NoteModificationResult result = handlePosting(request, noteStoringTO, noteId, parentNoteId,
            crossPostBlogAliasesSet, locale);
    if (publish) {
        cleanupAttachments(request, attachmentIds);
    }
    return createSuccessResponse(apiResult, result, locale);
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:67,代码来源:PostApiController.java

示例10: handleLogFile

import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
@Override
protected ModelAndView handleLogFile(HttpServletRequest request, HttpServletResponse response,
    LogDestination logDest) throws Exception {

  ModelAndView mv = new ModelAndView(getViewName());
  File file = logDest.getFile();

  if (file.exists()) {
    LinkedList<String> lines = new LinkedList<>();
    long actualLength = file.length();
    long lastKnownLength = ServletRequestUtils.getLongParameter(request, "lastKnownLength", 0);
    long currentLength =
        ServletRequestUtils.getLongParameter(request, "currentLength", actualLength);
    long maxReadLines = ServletRequestUtils.getLongParameter(request, "maxReadLines", 0);

    if (lastKnownLength > currentLength || lastKnownLength > actualLength
        || currentLength > actualLength) {

      // file length got reset
      lastKnownLength = 0;
      lines.add(" ------------- THE FILE HAS BEEN TRUNCATED --------------");
    }

    try (BackwardsFileStream bfs = new BackwardsFileStream(file, currentLength)) {
      BackwardsLineReader br;
      if (logDest.getEncoding() != null) {
        br = new BackwardsLineReader(bfs, logDest.getEncoding());
      } else {
        br = new BackwardsLineReader(bfs);
      }
      long readSize = 0;
      long totalReadSize = currentLength - lastKnownLength;
      String line;
      while (readSize < totalReadSize && (line = br.readLine()) != null) {
        if (!line.isEmpty()) {
          lines.addFirst(line);
          readSize += line.length();
        } else {
          readSize++;
        }
        if (maxReadLines != 0 && lines.size() >= maxReadLines) {
          break;
        }
      }

      if (lastKnownLength != 0 && readSize > totalReadSize) {
        lines.removeFirst();
      }
    }

    mv.addObject("lines", lines);
  }
  return mv;
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:55,代码来源:FollowController.java

示例11: handleLogFile

import org.springframework.web.bind.ServletRequestUtils; //导入方法依赖的package包/类
protected ModelAndView handleLogFile(HttpServletRequest request, HttpServletResponse response, LogDestination logDest) throws Exception {

        ModelAndView mv = new ModelAndView(getViewName());
        File file = logDest.getFile();

        if (file.exists()) {
            LinkedList lines = new LinkedList();
            long actualLength = file.length();
            long lastKnownLength = ServletRequestUtils.getLongParameter(request, "lastKnownLength", 0);
            long currentLength = ServletRequestUtils.getLongParameter(request, "currentLength", actualLength);
            long maxReadLines = ServletRequestUtils.getLongParameter(request, "maxReadLines", 0);

            if (lastKnownLength > currentLength
                    || lastKnownLength > actualLength
                    || currentLength > actualLength) {
                //
                // file length got reset
                //
                lastKnownLength = 0;
                lines.add(" ------------- THE FILE HAS BEEN TRUNCATED --------------");
            }

            BackwardsFileStream bfs = new BackwardsFileStream(file, currentLength);
            try {
                BackwardsLineReader br = new BackwardsLineReader(bfs);
                long readSize = 0;
                long totalReadSize = currentLength - lastKnownLength;
                String s;
                while (readSize < totalReadSize && (s = br.readLine()) != null) {
                    if (!s.equals("")){
                        lines.addFirst(s);
                        readSize += s.length();
                    } else {
                        readSize++;
                    }
                    if (maxReadLines != 0 && lines.size() >= maxReadLines) {
                        break;
                    }
                }

                if (lastKnownLength != 0 && readSize > totalReadSize) {
                    lines.removeFirst();
                }
            } finally {
                bfs.close();
            }
            
            mv.addObject("lines", lines);
        }
        return mv;
    }
 
开发者ID:andresol,项目名称:psi-probe-plus,代码行数:52,代码来源:FollowController.java


注:本文中的org.springframework.web.bind.ServletRequestUtils.getLongParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。