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


Java HttpStatus.INTERNAL_SERVER_ERROR属性代码示例

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


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

示例1: exception

@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!  ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append("\n\nroot cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:20,代码来源:ErrorController.java

示例2: newTransport

@Secured(USER)
@RequestMapping(value = "/new", method = POST)
public ResponseEntity<?> newTransport(@RequestBody TransportCreateDTO transportCreateDTO, Principal principal) {

    Optional<ValidationErrors> error = validators.validate(transportCreateDTO);
    if (error.isPresent()) {
        log.warn("Transport creation form had field errors.");
        return new ResponseEntity<>(error.get().getErrors(), HttpStatus.BAD_REQUEST);
    }

    Optional<User> owner = userService.findAndMapUser(principal.getName(), User.class);

    if (owner.isPresent() && transportService.save(transportCreateDTO, owner.get())) {
        log.debug("New transport added");
        return new ResponseEntity<>("New transport added.", HttpStatus.OK);
    } else {
        log.warn("Failed to add new transport.");
        return new ResponseEntity<>("Failed to add new transport.", HttpStatus.INTERNAL_SERVER_ERROR);
    }
}
 
开发者ID:RFTDevGroup,项目名称:RFTBackend,代码行数:20,代码来源:TransportController.java

示例3: findByName

/**
 * Fetch restaurants with the specified name. A partial case-insensitive
 * match is supported. So <code>http://.../restaurants/rest</code> will find
 * any restaurants with upper or lower case 'rest' in their name.
 *
 * @param name
 * @return A non-null, non-empty collection of restaurants.
 */
@HystrixCommand(fallbackMethod = "defaultRestaurants")
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<Collection<Restaurant>> findByName(@RequestParam("name") String name) {
    logger.info(String.format("restaurant-service findByName() invoked:{} for {} ", restaurantService.getClass().getName(), name));
    name = name.trim().toLowerCase();
    Collection<Restaurant> restaurants;
    try {
        restaurants = restaurantService.findByName(name);
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Exception raised findByName REST Call", ex);
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
    return restaurants.size() > 0 ? new ResponseEntity<>(restaurants, HttpStatus.OK)
            : new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:23,代码来源:RestaurantController.java

示例4: exception

@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!   ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append(" root cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:20,代码来源:ErrorController.java

示例5: findByName

/**
 * Fetch users with the specified name. A partial case-insensitive match is
 * supported. So <code>http://.../user/rest</code> will find any users with
 * upper or lower case 'rest' in their name.
 *
 * @param name
 * @return A non-null, non-empty collection of users.
 */
@HystrixCommand(fallbackMethod = "defaultUsers")
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<Collection<User>> findByName(@RequestParam("name") String name) {
    logger.info(String.format("user-service findByName() invoked:%s for %s ", userService.getClass().getName(), name));
    name = name.trim().toLowerCase();
    Collection<User> users;
    try {
        users = userService.findByName(name);
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Exception raised findByName REST Call", ex);
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
    return users.size() > 0 ? new ResponseEntity<>(users, HttpStatus.OK)
            : new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:23,代码来源:UserController.java

示例6: findById

/**
 * Fetch restaurants with the given id.
 * <code>http://.../v1/restaurants/{restaurant_id}</code> will return
 * restaurant with given id.
 *
 * @param id
 * @return A non-null, non-empty collection of restaurants.
 */
@HystrixCommand(fallbackMethod = "defaultRestaurant")
@RequestMapping(value = "/{restaurant_id}", method = RequestMethod.GET)
public ResponseEntity<Entity> findById(@PathVariable("restaurant_id") String id) {
    logger.info(String.format("restaurant-service findById() invoked:{} for {} ", restaurantService.getClass().getName(), id));
    id = id.trim();
    Entity restaurant;
    try {
        restaurant = restaurantService.findById(id);
    } catch (Exception ex) {
        logger.log(Level.WARNING, "Exception raised findById REST Call {0}", ex);
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
    return restaurant != null ? new ResponseEntity<>(restaurant, HttpStatus.OK)
            : new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:23,代码来源:RestaurantController.java

示例7: exception

@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuilder sb = new StringBuilder();
    sb.append("Exception during execution of Spring Security application!   ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append(" root cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    logger.error("error: {}", sb.toString(), throwable);

    return mav;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:22,代码来源:ErrorController.java

示例8: detectMeaningLanguageSpecific

@CrossOrigin
@RequestMapping(value = "/detectMeaningLanguageSpecific", method = RequestMethod.GET)
HttpEntity<Object> detectMeaningLanguageSpecific(@RequestParam("inputAsJson") String inputAsJson) {
	try {
		Logger.getAnonymousLogger().log(Level.INFO, "Invoke: detectMeaningLanguageSpecific: " + inputAsJson);
		Gson gson = new Gson();
		InputParameterdetectMeaningLanguageSpecific inputParameterdetectMeaningLanguageSpecific = gson
				.fromJson(inputAsJson, InputParameterdetectMeaningLanguageSpecific.class);
		List<Entity> concepts = sparqlDerivation.detectPossibleConceptsLanguageSpecific(
				inputParameterdetectMeaningLanguageSpecific.getKeyword(),
				inputParameterdetectMeaningLanguageSpecific.getLanguage());
		MeaningResult meaningResult = new MeaningResult();

		meaningResult.setConceptOverview(concepts);
		meaningResult.setSearchTyp("ExplorativeSearch");

		Gson output = new Gson();
		String result = "";
		result = output.toJson(meaningResult);

		return new ResponseEntity<Object>(result, HttpStatus.OK);
	} catch (Exception e) {
		return new ResponseEntity<Object>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
	}

}
 
开发者ID:nimble-platform,项目名称:catalog-search-service,代码行数:26,代码来源:SearchController.java

示例9: handleGlobalError

@ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Exception.class)
public ErrorDto handleGlobalError(Exception ex) {
    log.error("Global error handler exception: ", ex);
    return ErrorDto.builder()
            .errorCode(ErrorCodes.UNKNOWN)
            .message(ex.getLocalizedMessage())
            .build();
}
 
开发者ID:rozidan,项目名称:project-template,代码行数:9,代码来源:GlobalErrorHandlers.java

示例10: deleteByCode

@RequestMapping(value = "/{code:.*}", method = RequestMethod.DELETE)
public ResponseEntity deleteByCode(@PathVariable(CODE) String code) {
	try {
		this.messageManagementService.deleteMessage(code);
		return new ResponseEntity(HttpStatus.OK);
	} catch (I18nException exception) {
		LOG.info("Exception during deletion of message with code {}", code, exception);
	}
	return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
}
 
开发者ID:namics,项目名称:spring-i18n-support,代码行数:10,代码来源:MessageSourceDataController.java

示例11: findById

/**
 * Fetch restaurants with the given id.
 * <code>http://.../v1/restaurants/{restaurant_id}</code> will return
 * restaurant with given id.
 *
 * @param id
 * @return A non-null, non-empty collection of restaurants.
 */
@RequestMapping(value = "/{restaurant_id}", method = RequestMethod.GET)
public ResponseEntity<Entity> findById(@PathVariable("restaurant_id") String id) {
    logger.info(String.format("restaurant-service findById() invoked:{} for {} ", restaurantService.getClass().getName(), id));
    id = id.trim();
    Entity restaurant;
    try {
        restaurant = restaurantService.findById(id);
    } catch (Exception ex) {
        logger.log(Level.WARNING, "Exception raised findById REST Call {0}", ex);
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
    return restaurant != null ? new ResponseEntity<>(restaurant, HttpStatus.OK)
            : new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:22,代码来源:RestaurantController.java

示例12: findByName

/**
 * Fetch bookings with the specified name. A partial case-insensitive match
 * is supported. So <code>http://.../booking/rest</code> will find any
 * bookings with upper or lower case 'rest' in their name.
 *
 * @param name
 * @return A non-null, non-empty collection of bookings.
 */
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<Collection<Booking>> findByName(@RequestParam("name") String name) {
    logger.info(String.format("booking-service findByName() invoked:{} for {} ", bookingService.getClass().getName(), name));
    name = name.trim().toLowerCase();
    Collection<Booking> bookings;
    try {
        bookings = bookingService.findByName(name);
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Exception raised findByName REST Call", ex);
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
    return bookings.size() > 0 ? new ResponseEntity<>(bookings, HttpStatus.OK)
            : new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:22,代码来源:BookingController.java

示例13: handle

@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Throwable.class)
@ResponseBody
public ErrorResponse handle(final Throwable ex) {
    log.error("Unexpected error", ex);
    return new ErrorResponse("INTERNAL_SERVER_ERROR", "An unexpected internal server error occured");
}
 
开发者ID:nielsutrecht,项目名称:spring-boot-aop,代码行数:7,代码来源:ExceptionHandlers.java

示例14: generateServerForLanguage

@RequestMapping(value = "/servers", method = RequestMethod.POST)
public ResponseEntity<byte[]> generateServerForLanguage(@RequestParam("serverLanguage") String serverLanguage,
                                                        GeneratorInput opts,
                                                        @RequestParam(value = "id") Integer id,
                                                        @RequestParam(value = "apiPackage", required = false) String apiPackage,
                                                        @RequestParam(value = "artifactId") String artifactId,
                                                        @RequestParam(value = "groupId") String groupId,
                                                        @RequestParam(value = "convert", defaultValue = "false") boolean convert) throws Exception {


    Map<String, String> options = opts.getOptions();
    if (options == null) {
        options = new HashMap<>();
        opts.setOptions(options);
    }

    if (StringUtils.isNotBlank(apiPackage)) {
        options.put(CodegenConstants.MODEL_PACKAGE, apiPackage + ".model");
        options.put(CodegenConstants.API_PACKAGE, apiPackage + ".api");
    } else {
        options.put(CodegenConstants.MODEL_PACKAGE, "model");
        options.put(CodegenConstants.API_PACKAGE, "api");
    }

    options.put(CodegenConstants.INVOKER_PACKAGE, apiPackage);
    options.put(CodegenConstants.ARTIFACT_ID, artifactId);
    options.put(CodegenConstants.GROUP_ID, groupId);
    options.put(SpringCodegen.BASE_PACKAGE, apiPackage);


    if (serverLanguage.equalsIgnoreCase("springcloud") ||
            serverLanguage.equalsIgnoreCase("springmvc") ||
            serverLanguage.equalsIgnoreCase("springboot")) {
        if (serverLanguage.equalsIgnoreCase("springcloud")) {
            options.put(CodegenConstants.LIBRARY, SpringCodegen.SPRING_CLOUD_LIBRARY);
        } else if (serverLanguage.equalsIgnoreCase("springmvc")) {
            options.put(CodegenConstants.LIBRARY, SpringCodegen.SPRING_MVC_LIBRARY);
        } else {
            options.put(CodegenConstants.LIBRARY, SpringCodegen.DEFAULT_LIBRARY);
        }

        options.put(JavaClientCodegen.USE_RX_JAVA, "true");
        options.put(SpringCodegen.CONFIG_PACKAGE, apiPackage + "/config");
        options.put(CodegenConstants.INVOKER_PACKAGE, apiPackage);
        options.put(CodegenConstants.SOURCE_FOLDER, "src/main/java/");
        //使用java 自带的时间
        options.put(JavaClientCodegen.DATE_LIBRARY, "legacy");
        serverLanguage = "spring";
    }
    options.put(SpringCodegen.BASE_PACKAGE, apiPackage);

    if (serverLanguage.equals("go")) {
        options.put(CodegenConstants.PACKAGE_NAME, apiPackage);
    }
    Document document = documentService.findOne(id);
    Swagger swagger = new SwaggerParser()
            .parse(document.getContent());
    if (swagger == null) {
        throw new BadRequestException("The swagger specification supplied was not valid");
    }
    swagger = Generator.convertSwagger(swagger);
    String filename = Generator.generateServer(serverLanguage, swagger, opts);

    if (filename != null) {
        return downloadFile(new File(filename), artifactId);
    } else {
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
}
 
开发者ID:wu191287278,项目名称:sc-generator,代码行数:69,代码来源:SwaggerController.java

示例15: handleJsonParsing

@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR, reason = "Exception during processing, examine server Logs")
@ExceptionHandler(JsonParseException.class)
public void handleJsonParsing(HttpServletRequest request,Exception e) {
	logger.warn( "{}: {}", request.getRequestURI(),CSAP.getCsapFilteredStackTrace( e ));
	logger.debug( "Full exception", e );
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:6,代码来源:ErrorHandling.java


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