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


Java ResponseBody类代码示例

本文整理汇总了Java中org.springframework.web.bind.annotation.ResponseBody的典型用法代码示例。如果您正苦于以下问题:Java ResponseBody类的具体用法?Java ResponseBody怎么用?Java ResponseBody使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ResponseBody类属于org.springframework.web.bind.annotation包,在下文中一共展示了ResponseBody类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: savePrefs

import org.springframework.web.bind.annotation.ResponseBody; //导入依赖的package包/类
@RequestMapping(value="/prefs", headers = "Accept=application/json; charset=utf-8")
@ResponseBody
public void savePrefs(@RequestParam List<String> values, @RequestParam String key) {
	Authentication auth = SecurityContextHolder.getContext().getAuthentication();
	String eppn = auth.getName();
	
	try {
		preferencesService.setPrefs(eppn, key, StringUtils.join(values, ","));
		if(KEYRM.equals(key)){
			List <String>  prefsStats = new ArrayList<String>(Arrays.asList(preferencesService.getPrefs(eppn, KEY).getValue().split("\\s*,\\s*")));
			prefsStats.remove(values.get(0));
		}
		
	} catch (Exception e) {
		log.warn("Impossible de sauvegarder les préférences", e);
	}
}
 
开发者ID:EsupPortail,项目名称:esup-sgc,代码行数:18,代码来源:StatsController.java

示例2: getRelationsCounts

import org.springframework.web.bind.annotation.ResponseBody; //导入依赖的package包/类
@RequestMapping(value="/cm/simple/relations/count", method = RequestMethod.GET)
@ResponseBody
public Map<String, Long> getRelationsCounts(
		@RequestParam(value="nsPath", required = true) String nsPath,
		@RequestParam(value="ciId", required = false) Long ciId,
		@RequestParam(value="direction", required = true) String direction, 
		@RequestParam(value="relationName", required = false) String relationName,
		@RequestParam(value="relationShortName", required = false) String shortRelationName,
		@RequestParam(value="targetClassName", required = false) String targetClazz,
		@RequestParam(value="recursive", required = false)  Boolean recursive,
		@RequestParam(value="groupBy", required = false) String groupBy,
		@RequestHeader(value="X-Cms-Scope", required = false)  String scope){

	if (scope != null) {
		scopeVerifier.verifyScope(scope, nsPath);
	}
	if (recursive == null) {
		recursive = false;
	}
	CmsDataHelper<RelationParam, Map<String, Long>> dataHelper = new CmsDataHelper<>();
	RelationParam param = new RelationParam(nsPath, relationName, shortRelationName, targetClazz, recursive);
	param.setCiId(ciId);
	param.setDirection(direction);
	param.setGroupBy(groupBy);
	return dataHelper.execute(this::getRelationsCountsInternal, param, isOrgLevelRecursiveAccess(nsPath, recursive), "getRelationsCounts");
}
 
开发者ID:oneops,项目名称:oneops,代码行数:27,代码来源:CmRestController.java

示例3: startCron

import org.springframework.web.bind.annotation.ResponseBody; //导入依赖的package包/类
/**
 * 启动计划任务
 */
@RequestMapping(value = "/start", method = {RequestMethod.POST,RequestMethod.GET})
@ResponseBody
public String startCron(String cron_id){
	LOG.info("request /api/v2/cron/start start");
	Map<String,Object>  result = new HashMap<String, Object>();
	result.put("flag", "false");
	if(cron_id.length() != 16){
		result.put("error", Errorcode.ERR403_9.getValue());
		return JSON.toJSONString(result, JsonFilter.filter);
	}
	try{
		Map<String,Object>  mqrequest = new HashMap<String, Object>();
		mqrequest.put("id",cron_id );
		result = messageProducer.call("openapi.cron","startCron", mqrequest, 5000);
	}catch(Exception e){
		result.put("error", Errorcode.ERR500.getValue()+",openapi try/catch:"+ExceptionUtil.getStackTraceAsString(e));
	}
    	return JSON.toJSONString(result,JsonFilter.filter);
}
 
开发者ID:elves-project,项目名称:openapi,代码行数:23,代码来源:CronWebService.java

示例4: updateOrganize

import org.springframework.web.bind.annotation.ResponseBody; //导入依赖的package包/类
/**
 * 编辑组织机构
 * @param orgName 组织名称
 * @param parentOrgId 父组织id
 * @param remark 组织描述
 * @return
 */
@ResponseBody
@RequiresPermissions("system:organize:edit")
@MumuLog(name = "编辑组织机构",operater = "PUT")
@RequestMapping(value="/edit",method=RequestMethod.PUT)
public ResponseEntity updateOrganize(int orgId,String orgName,String parentOrgId,String remark){
    List<SysOrganize> organizes=organizeService.querySysOrganizeByCondition(orgName);
    if(organizes!=null&&organizes.size()>0&&organizes.get(0).getOrgId()!=orgId){
        return new ResponseEntity(500, "组织机构名称不可重复", null);
    }
    try {
        SysOrganize organize=new SysOrganize();
        organize.setOrgId(orgId);
        organize.setOrgName(orgName);
        organize.setParentOrgId(Integer.parseInt(parentOrgId));
        organize.setRemark(remark);
        organize.setEditor(SecurityUtils.getSubject().getPrincipal().toString());
        organizeService.updateSysOrganize(organize);
        return new ResponseEntity(200, "更新组织机构成功", null);
    } catch (NumberFormatException e) {
        log.error(e);
        return new ResponseEntity(500, "更新组织机构出现异常", null);
    }
}
 
开发者ID:babymm,项目名称:mumu,代码行数:31,代码来源:SysOrganizeController.java

示例5: checkName

import org.springframework.web.bind.annotation.ResponseBody; //导入依赖的package包/类
@RequestMapping("role-def-checkName")
@ResponseBody
public boolean checkName(@RequestParam("name") String name,
        @RequestParam(value = "id", required = false) Long id)
        throws Exception {
    String hql = "from RoleDef where tenantId="
            + tenantHolder.getTenantId() + " and name=?";
    Object[] params = { name };

    if (id != null) {
        hql = "from RoleDef where tenantId=" + tenantHolder.getTenantId()
                + " and name=? and id<>?";
        params = new Object[] { name, id };
    }

    boolean result = roleDefManager.findUnique(hql, params) == null;

    return result;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:20,代码来源:RoleDefController.java

示例6: webUploaderBinary

import org.springframework.web.bind.annotation.ResponseBody; //导入依赖的package包/类
/**
 * WebUploader插件当使用二进制流的方式上传图片时接收方法
 *
 * @param request
 * @param response
 * @return
 * @throws java.io.IOException
 */
@RequestMapping(value = "/webUploaderBinary", method = RequestMethod.POST)
@ResponseBody
public String webUploaderBinary(HttpServletRequest request, HttpServletResponse response) throws IOException {
    ServletInputStream inputStream = request.getInputStream();

    BufferedInputStream in = new BufferedInputStream(inputStream);
    FileOutputStream out = new FileOutputStream(new File("d:/test.jpg"));

    int b = -1;
    byte[] bytes = new byte[1024];

    while ((b = in.read(bytes, 0, bytes.length)) != -1) {
        out.write(b);
    }

    out.close();
    in.close();

    return "success";
}
 
开发者ID:jthinking,项目名称:image-server,代码行数:29,代码来源:ImageController.java

示例7: oneRawImage

import org.springframework.web.bind.annotation.ResponseBody; //导入依赖的package包/类
@GetMapping(value = BASE_PATH + "/" + FILENAME + "/raw",
	produces = MediaType.IMAGE_JPEG_VALUE)
@ResponseBody
public Mono<ResponseEntity<?>> oneRawImage(
	@PathVariable String filename) {
	// tag::try-catch[]
	return imageService.findOneImage(filename)
		.map(resource -> {
			try {
				return ResponseEntity.ok()
					.contentLength(resource.contentLength())
					.body(new InputStreamResource(
						resource.getInputStream()));
			} catch (IOException e) {
				return ResponseEntity.badRequest()
					.body("Couldn't find " + filename +
						" => " + e.getMessage());
			}
		});
	// end::try-catch[]
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:22,代码来源:HomeController.java

示例8: logout

import org.springframework.web.bind.annotation.ResponseBody; //导入依赖的package包/类
/**
 * @desc 退出系统
 *
 * @author liuliang
 *
 * @param request
 * @return
 */
@RequestMapping(value = "/logout")
@ResponseBody
public Result logout(HttpServletRequest request){
	Result result = new Result();
	try {
		String ticket = CookieUtil.getCookieValueByName(request,TitanConstant.TICKET_PREFIX);
		if(StringUtils.isNotBlank(ticket)){
			jedisCluster.del(TitanConstant.TICKET_PREFIX + ticket);
			return ResultUtil.success(result);
		}else {
			logger.error("ticket为空,ticket:{}",ticket);
			return ResultUtil.fail(ErrorCode.REQUEST_PARA_ERROR,result);
		}
	} catch (Exception e) {
		logger.error("退出titan异常",e);
	}
	return ResultUtil.fail(result);
}
 
开发者ID:yunjiweidian,项目名称:TITAN,代码行数:27,代码来源:LoginController.java

示例9: destroySsoSession

import org.springframework.web.bind.annotation.ResponseBody; //导入依赖的package包/类
/**
 * Endpoint for destroying a single SSO Session.
 *
 * @param ticketGrantingTicket the ticket granting ticket
 * @param request              the request
 * @param response             the response
 * @return result map
 */
@PostMapping(value = "/destroySsoSession")
@ResponseBody
public Map<String, Object> destroySsoSession(@RequestParam final String ticketGrantingTicket,
                                             final HttpServletRequest request,
                                             final HttpServletResponse response) {
    ensureEndpointAccessIsAuthorized(request, response);

    final Map<String, Object> sessionsMap = new HashMap<>(1);
    try {
        this.centralAuthenticationService.destroyTicketGrantingTicket(ticketGrantingTicket);
        sessionsMap.put(STATUS, HttpServletResponse.SC_OK);
        sessionsMap.put(TICKET_GRANTING_TICKET, ticketGrantingTicket);
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
        sessionsMap.put(STATUS, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        sessionsMap.put(TICKET_GRANTING_TICKET, ticketGrantingTicket);
        sessionsMap.put("message", e.getMessage());
    }
    return sessionsMap;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:29,代码来源:SingleSignOnSessionsReportController.java

示例10: findByFrom

import org.springframework.web.bind.annotation.ResponseBody; //导入依赖的package包/类
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = { "fromId", "fromType" })
@ResponseBody
public List<EntityRelation> findByFrom(@RequestParam("fromId") String strFromId,
    @RequestParam("fromType") String strFromType,
    @RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws IoTPException {
  checkParameter("fromId", strFromId);
  checkParameter("fromType", strFromType);
  EntityId entityId = EntityIdFactory.getByTypeAndId(strFromType, strFromId);
  checkEntityId(entityId);
  RelationTypeGroup typeGroup = parseRelationTypeGroup(strRelationTypeGroup, RelationTypeGroup.COMMON);
  try {
    return checkNotNull(relationService.findByFrom(entityId, typeGroup).get());
  } catch (Exception e) {
    throw handleException(e);
  }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:18,代码来源:EntityRelationController.java

示例11: getStockBoard

import org.springframework.web.bind.annotation.ResponseBody; //导入依赖的package包/类
@RequestMapping(value = "/stockboard", method = RequestMethod.GET)
public
@ResponseBody
StockBoardModel getStockBoard(@RequestParam Long entityId, HttpServletRequest request) {
  KioskConfig kc = null;
  StockBoardModel model = new StockBoardModel();
  StockBoardBuilder stockBoardBuilder = new StockBoardBuilder();
  SecureUserDetails sUser = SecurityUtils.getUserDetails(request);
  Locale locale = sUser.getLocale();
  ResourceBundle backendMessages = Resources.get().getBundle("BackendMessages", locale);
  try {
    if (entityId != null) {
      kc = KioskConfig.getInstance(entityId);
      if (kc != null) {
        model = stockBoardBuilder.buildStockBoardModel(kc, model);
      }
    }
    return model;
  } catch (Exception e) {
    xLogger.severe("Exception when retrieving stock board config");
    throw new InvalidServiceException(backendMessages.getString("stock.board.config.fetch"));
  }

}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:25,代码来源:EntityController.java

示例12: delete

import org.springframework.web.bind.annotation.ResponseBody; //导入依赖的package包/类
@RequestMapping(value = "/del.d", produces = "application/json;charset=UTF-8")
@ResponseBody
public String delete(@RequestParam("id") int id) {
    JSONObject output = new JSONObject();
    JSONObject server = new JSONObject();
    output.put("result", server);
    try {
        boolean result = service.deleteByIds(Arrays.asList(id));
        if (result) {
            server.put("code", SvrResult.OK.getCode());
            server.put("msg", SvrResult.OK.getMsg());
        } else {
            server.put("code", SvrResult.ERROR.getCode());
            server.put("msg", SvrResult.ERROR.getMsg());
        }
    } catch (Exception e) {
        server.put("code", -1.);
        server.put("msg", e.getMessage());
        logger.error("Exception:", e);
    }
    return output.toJSONString();
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:23,代码来源:UserController.java

示例13: asynchAction

import org.springframework.web.bind.annotation.ResponseBody; //导入依赖的package包/类
@RequestMapping(value="/web/react.json",produces ="application/json",method = RequestMethod.GET,headers = {"Accept=text/xml, application/json"})
@ResponseBody
public Callable<Employee> asynchAction(){
	Callable<Employee> task = new Callable<Employee>() {
		
		
           @Override
           public Employee call () throws Exception {
           	logger.info("controller#asynchAction task started.");
               System.out.println("controller#async task started. Thread: " +
                                                      Thread.currentThread()
                                                            .getName());
               Thread.sleep(5000);
               Employee emp = employeeServiceImpl.readEmployee(15).get();
               System.out.println(emp.getLastName());
               return emp;
           }
       };
	return task;
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:21,代码来源:DataController.java

示例14: checkuse

import org.springframework.web.bind.annotation.ResponseBody; //导入依赖的package包/类
/**
 * 检查用户名是否可用
 * @param empName
 * @return
 */
@ResponseBody
@RequestMapping("/checkuser")
public Msg checkuse(@RequestParam("empName")String empName){
	//先判断用户名是否是合法的表达式
	String regx="(^[a-zA-Z0-9_-]{6,16}$)|(^[\u2E80-\u9FFF]{2,5})";
	
	if(!(empName.matches(regx))){
		System.out.println("不可用");
		return Msg.fail().add("va_msg","用户名必须是6-16位数字和字母的组合或者2-5位中文");
	}
	
	//数据库用户名重复校验
	boolean b =employeeService.checkUser(empName);
	if(b){
		return Msg.success();
	}else{
		return Msg.fail().add("va_msg", "用户名不可用");
	}

}
 
开发者ID:xpppp111,项目名称:SSM-,代码行数:26,代码来源:EmployeeController.java

示例15: orderSearch

import org.springframework.web.bind.annotation.ResponseBody; //导入依赖的package包/类
@RequestMapping("search.do")
@ResponseBody
public ServerResponse<PageInfo> orderSearch(HttpSession session, Long orderNo,@RequestParam(value = "pageNum",defaultValue = "1") int pageNum,
                                            @RequestParam(value = "pageSize",defaultValue = "10")int pageSize){
    User user = (User)session.getAttribute(Const.CURRENT_USER);
    if(user == null){
        return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户未登录,请登录管理员");

    }
    if(iUserService.checkUserRole(user).isSuccess()){
        //填充我们增加产品的业务逻辑
        return iOrderService.manageSearch(orderNo,pageNum,pageSize);
    }else{
        return ServerResponse.createByError("无权限操作");
    }
}
 
开发者ID:wangshufu,项目名称:mmall,代码行数:17,代码来源:OrderManageController.java


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