小编Nei*_*ilA的帖子

Thymeleaf:连接 - 无法解析为表达式

我在尝试在模板中连接多个值时遇到问题.根据Thymeleaf 在这里我应该只是能够+他们在一起......

4.6加强文本

文本,无论是文字还是评估变量或消息表达式的结果,都可以使用+运算符轻松连接:

th:text="'The name of the user is ' + ${user.name}"
Run Code Online (Sandbox Code Playgroud)

以下是我发现的工作示例:

<p th:text="${bean.field} + '!'">Static content</p>
Run Code Online (Sandbox Code Playgroud)

然而,这不是:

<p th:text="${bean.field} + '!' + ${bean.field}">Static content</p>
Run Code Online (Sandbox Code Playgroud)

从逻辑上讲,这应该有效,但不是,我做错了什么?


Maven的:

<dependency>
    <groupId>org.thymeleaf</groupId>
    <artifactId>thymeleaf-spring3</artifactId>
    <version>2.0.16</version>
    <scope>compile</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

以下是我设置TemplateEngine和TemplateResolver的方法:

<!-- Spring config -->
<bean id="templateResolver" class="org.thymeleaf.templateresolver.ClassLoaderTemplateResolver">
    <property name="suffix" value=".html"/>
    <property name="templateMode" value="HTML5"/>
    <property name="characterEncoding" value="UTF-8"/>
    <property name="order" value="1"/>
</bean>
<bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
    <property name="templateResolver" ref="fileTemplateResolver"/>
    <property name="templateResolvers">
        <list>
            <ref bean="templateResolver"/>
        </list>
    </property>
Run Code Online (Sandbox Code Playgroud)

ThymeleafTemplatingService:

@Autowired private TemplateEngine templateEngine;
.....
String responseText = this.templateEngine.process(templateBean.getTemplateName(), …
Run Code Online (Sandbox Code Playgroud)

html java thymeleaf

67
推荐指数
4
解决办法
8万
查看次数

HashMap的自定义哈希码/等于操作

是否有一个HashMap类(或Map接口)的实现,它允许我使用备用哈希码和等于操作...类似于如何使用Collections.sort中的Comparator以多种方式对相同类型的集合进行排序(列表,比较器).

我想尽可能避免,创建一个提供所需哈希码和等于操作的密钥包装器.


就我而言,我需要这样的场景之一:

在我的Web应用程序中,对于每个请求,我加载位置/ ISP和其他数据.在代码的不同部分(在我的服务和存储库层中),我已经"最小化"特定于其需求的缓存.

这是一个简化的代码示例:

class GeoIpData{
    private String countryName;
    private String state;
    private String city;
    private String isp;
    @Override
    public int hashCode() {
        //countryName hashCode
        //state hashCode
        //city hashCode
        //isp hashCode
    }
    @Override
    public boolean equals(Object obj) {
        // compare countryName
        // compare state
        // compare city
        // compare isp
    }
}

 Map<GeoIpData,#Type1> fullCache = ... //This cache needs to be unique per countryName,state,city and isp
 Map<GeoIpData,#Type2> countryCache = ... //This cache needs to be unique per countryName …
Run Code Online (Sandbox Code Playgroud)

java overriding equals hashmap hashcode

5
推荐指数
1
解决办法
1540
查看次数

如何从STS引导仪表板中删除不需要的项目

我正在使用Eclipse STS 3.8.1

无论如何,要从启动仪表板中删除应用程序吗?

询问原因(类似于我的实际应用程序):
我有多个Spring Boot应用程序,其中一些使用共享库。在这个库中,我有一些常用的配置:例如:使用Ribbon(@LoadBalancer)设置RestTemplate / s。

为了访问@Configuration和@Bean批注,我在库pom中包括以下依赖项:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>1.4.0.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

现在的问题是,即使我的库不是启动应用程序,它也会与应用程序一起显示在启动仪表盘中。

这很烦人,因为它使仪表板杂乱无章,如何删除它?


只是为了扩展我上面的示例:
我正在使用一个多模块Maven项目,在同一个父项下有多个应用程序和库。

spring maven-2 spring-tool-suite spring-boot

5
推荐指数
1
解决办法
1060
查看次数