我想将此字符串“ 123456”转换为十六进制 String.format("%016x", "123456")
但我有一个错误
Exception in thread "main" java.util.IllegalFormatConversionException: x != java.lang.String
at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4302)
at java.util.Formatter$FormatSpecifier.printInteger(Formatter.java:2793)
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2747)
at java.util.Formatter.format(Formatter.java:2520)
at java.util.Formatter.format(Formatter.java:2455)
at java.lang.String.format(String.java:2940)
at Asdfsaf.main(Asdfsaf.java:22)
Run Code Online (Sandbox Code Playgroud) 据我所知,Java 8引入了一种可用于Collection类型的新方法:removeif()。它接受一个谓词,该谓词定义了应删除元素的条件。它返回一个布尔值,其中“真”响应表示已删除至少一个项目,否则返回“假”:我有此类:
HotelPriceSummary {
Hotel hotel;
float price
}
Run Code Online (Sandbox Code Playgroud)
一种 List<HotelPriceSummary> allHotels;
和 Iterable<Hotel> discardedHotels
我想做类似的事情(显然,existIn是一个不存在的函数,是表达我想做的事情,但我没有找到方法)
allHotels.removeIf(h -> h.getHotel().existsIn (discardedHotels))
Run Code Online (Sandbox Code Playgroud) 我有一个带有以下 pom.xml 的 SpringBoot 应用程序:
\n\n...\n<parent>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-parent</artifactId>\n <version>2.0.6.RELEASE</version>\n <relativePath/> \n </parent>\n\n<!-- Spring Security -->\n <dependency>\n <groupId>org.thymeleaf.extras</groupId>\n <artifactId>thymeleaf-extras-springsecurity4</artifactId>\n </dependency>\n...\n
Run Code Online (Sandbox Code Playgroud)\n\n并且运行良好。\n然后我将 SpringBoot 版本更新为
\n\n...\n <parent>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-parent</artifactId>\n <version>2.1.0.RELEASE</version>\n <relativePath/> \n </parent>\n\n <dependency>\n <groupId>org.thymeleaf.extras</groupId>\n <artifactId>thymeleaf-extras-springsecurity4</artifactId>\n <version>3.0.4.RELEASE</version> \n </dependency>\n...\n
Run Code Online (Sandbox Code Playgroud)\n\n我在 1 个模板中收到此错误:
\n\nException evaluating SpringEL expression: "#authorization.expression(\'hasRole(\'\'ROLE_ADMIN\'\')\')" (template: "tdk/common/menu" - line 87, col 21)\n
Run Code Online (Sandbox Code Playgroud)\n\n这里是模板:
\n\n <li th:if="${#authorization.expression(\'hasRole(\'\'ROLE_ADMIN\'\')\')}" class="menu-principal pure-menu-item" th:classappend="${activeMenuItem == \xe2\x80\x98tdkMessages\'} ? pure-menu-selected">\n <a href=\xe2\x80\x9c/tdk/list" class="pure-menu-link">\n <i class="fas fa-cloud-download-alt fa-lg fa-fw"></i> tdk\n </a>\n </li>\n
Run Code Online (Sandbox Code Playgroud)\n 我有这段代码:
userAvailableRoles.stream()
.peek(x-> x.setPets(userPets(roles, hasValidAccess)));
Run Code Online (Sandbox Code Playgroud)
但我有这个警告:
Warning:(86, 18) Result of 'Stream.peek()' is ignored
Run Code Online (Sandbox Code Playgroud) 在Spring RESTful Web Services中,所有REST(Representational State Transfer)方法都是幂等的吗?
java ×3
collections ×1
hex ×1
java-8 ×1
java-stream ×1
lambda ×1
numbers ×1
spring ×1
spring-boot ×1
spring-el ×1
spring-mvc ×1
spring-rest ×1
thymeleaf ×1