我在pom.xml中有一个带有Spring Data Elasticsearch插件的Spring Boot应用程序.我创建了一个文档类,我想索引:
@Document(indexName = "operations", type = "operation")
public class OperationDocument {
@Id
private Long id;
@Field(
type = FieldType.String,
index = FieldIndex.analyzed,
searchAnalyzer = "standard",
indexAnalyzer = "standard",
store = true
)
private String operationName;
@Field(
type = FieldType.Date,
index = FieldIndex.not_analyzed,
store = true,
format = DateFormat.custom, pattern = "dd.MM.yyyy hh:mm"
)
private Date dateUp;
@Field(
type = FieldType.String,
index = FieldIndex.not_analyzed,
store = false
)
private String someTransientData;
@Field(type = FieldType.Nested)
private List<Sector> sectors;
//Getter …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用一个服务,它为我提供了一个具有字段的实体,它是一个数组.
{
"id": "23233",
"items": [
{
"name": "item 1"
},
{
"name": "item 2"
}
]
}
Run Code Online (Sandbox Code Playgroud)
但是当数组包含单个项时,将返回项本身,而不是一个元素的数组.
{
"id": "43567",
"items": {
"name": "item only"
}
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,杰克逊无法转换为我的Java对象.
public class ResponseItem {
private String id;
private List<Item> items;
//Getters and setters...
}
Run Code Online (Sandbox Code Playgroud)
有一个简单的解决方案吗?
我正在使用thymeleaf-spring3 2.0.18和Spring 3.1.1.我已经完成了一个工作正常的登录页面,但是,在解析其他Thymeleaf属性时,"sec:authorize"不是,因为如果我查看生成的视图的源代码,我可以看到它们.
是否有我缺少的东西,如依赖或特定配置?
这是我的login.html:
<!DOCTYPE html>
<head>
...
</head>
<body>
<div class="top">
<div class="container">
<ul class="loginbar pull-right">
<li sec:authorize="isAnonymous()"><a href="/login" class="login-btn">Login</a></li>
<li sec:authorize="isAuthenticated()" class="login-btn">Welcome <span sec:authentication="name">Bob</span></li>
</ul>
</div>
</div><!--/top-->
<!--=== Content Part ===-->
<div class="container">
<div class="row-fluid">
<form name="f" th:action="@{/j_spring_security_check}" method="post" class="log-page">
<h3>Login</h3>
<div th:if="${loginError}" th:with="errorMsg=${session['SPRING_SECURITY_LAST_EXCEPTION'].message}" class="alert alert-error">
Bad user or password.<br/>
Cause: <span th:text="${errorMsg}">Wrong input!</span>
</div>
<div class="input-prepend">
<span class="add-on"><i class="icon-user"></i></span>
<input name="j_username" class="input-xlarge" type="text" placeholder="Username" />
</div>
<div class="input-prepend">
<span class="add-on"><i class="icon-lock"></i></span>
<input …Run Code Online (Sandbox Code Playgroud)