我在Windows机器上运行Java程序.我正在尝试获取时区列表及其相关信息.这是完整的程序:
String[] allTimeZones = TimeZone.getAvailableIDs();
Date now = new Date();
for (int i = 0; i < allTimeZones.length; i++) {
TimeZone tz = TimeZone.getTimeZone(allTimeZones[i]);
System.out.format("%s;%s; %f \n",
allTimeZones[i],
tz.getDisplayName(),
(float) (tz.getOffset(now.getTime())/3600000.0));
}
Run Code Online (Sandbox Code Playgroud)
其中一个生成的时区具有以下信息:
America/New_York;东部标准时间; -4.000000
这令人费解.此时,纽约正处于东夏夏令时.所以上面的信息不对.
有谁知道如何让Java生成
America/New_York;东部标准时间; -5.000000
或类似的东西
America/New_York;东夏夏令时; -4.000000
感谢帮助!
问候
我正在学习Bootstrap,并希望有一个所见即所得的编辑器.我找到了bootstrap-wysiwyg 并希望使用它.
http://mindmup.github.io/bootstrap-wysiwyg/
但是,在提交表单时,我无法弄清楚如何在服务器端获取格式化文本.
我有以下简单的HTML页面:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div>
méywe
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在Chrome或Firefox中显示它时(我没有测试其他浏览器),我看到以下内容:
mywe
我错过了什么?html文件以UTF-8编码保存.服务器是Apache.我的机器是Windows 7专业版.文本编辑器是UltraEdit.
谢谢!
更新
最初,我使用UltraEdit编辑这个html文件,我遇到了问题.基于cmbuckley对Notepad ++的输入和安装(来自Heatmanofurioso的建议),我想到了我的文件以某种方式被破坏的可能性(即使它在UltraEdit和Notepad中看起来都很好).所以我用utf-8编码的记事本保存了我的文件.仍然看到了问题(可能是由于缓存???).然后我用UltraEdit再次保存它.查看浏览器中的页面,问题就消失了.
学过的知识
有两个文本编辑器,如果那是你的工具,如果你看到无法解释的问题,请尝试不同的编辑器.即使您每天使用一个工具,也没有完美的工具.就我而言,Notepad ++修复了我的文件的utf8问题,UltraEdit以某种方式失败了.
感谢大家帮忙!!!
在我的控制器中,我有以下内容将存储在CSHTML文件中的HTML片段发送到前面.
public FileResult htmlSnippet(string fileName)
{
string contentType = "text/html";
return new FilePathResult(fileName, contentType);
}
Run Code Online (Sandbox Code Playgroud)
fileName如下所示:
/file/abc.cshtml
现在让我感到困扰的是,这些HTML代码段文件具有西班牙语字符,当它们显示在页面中时看起来不正确.
感谢致敬.
我正在尝试升级到ES 2.0.我已经下载了ES 2.0并将其安装在我的Windows机器上.
在我的pom.xml中,我有以下内容:
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.0.0-rc1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>delete-by-query</artifactId>
<version>2.0.0-rc1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
在我的Java代码中,使用ES 1.7.3时,我按以下方式通过查询删除:
StringBuilder b = new StringBuilder("");
b.append("{");
b.append(" \"query\": {");
b.append(" \"term\": {");
b.append(" \"category\": " + category_value );
b.append(" }");
b.append(" }");
b.append("}");
client = getClient();
DeleteByQueryResponse response = client.prepareDeleteByQuery("myindex")
.setTypes("mydocytype")
.setSource(b.toString())
.execute()
.actionGet();
Run Code Online (Sandbox Code Playgroud)
我希望能取代这个:
DeleteByQueryResponse response = client.prepareDeleteByQuery("myindex")
.setTypes("mydocytype")
.setSource(b.toString())
.execute()
.actionGet();
Run Code Online (Sandbox Code Playgroud)
用ES 2.0方式.谷歌搜索但没有找到它的例子.在线API文档对我来说太抽象了.我该怎么做?
另一个问题:我是否必须在Elasticsearch服务器中安装delete-by-query插件?
谢谢你的指针!
UPDATE
我遵循马克斯的建议,这就是我现在所拥有的:
首先,在创建客户端时,使设置如下所示:
Settings settings = Settings.settingsBuilder()
.put("cluster.name", "mycluster")
.put("plugin.types", DeleteByQueryPlugin.class.getName())
.build();
Run Code Online (Sandbox Code Playgroud)
其次,在按查询删除的地方:
DeleteByQueryResponse rsp = new …Run Code Online (Sandbox Code Playgroud) 我有一个使用 Spring Data 1.6.1.RELEASE 构建的 Web 应用程序。它通过遵循 Spring Data 在线文档中的示例在所有存储库中添加自定义行为:
1.3.2 向所有存储库添加自定义行为 https://docs.spring.io/spring-data/data-commons/docs/1.6.1.RELEASE/reference/html/repositories.html
基本上,它使用如下所示的自定义行为扩展 JpaRepository:
public interface MyRepository<T, ID extends Serializable>
extends JpaRepository<T, ID> {
void sharedCustomMethod(ID id);
}
Run Code Online (Sandbox Code Playgroud)
下面是这个新接口的实现代码:
public class MyRepositoryImpl<T, ID extends Serializable>
extends SimpleJpaRepository<T, ID> implements MyRepository<T, ID> {
private EntityManager entityManager;
public MyRepositoryImpl(Class<T> domainClass, EntityManager entityManager) {
super(domainClass, entityManager);
this.entityManager = entityManager;
}
public void sharedCustomMethod(ID id) {
// implementation goes here
}
}
Run Code Online (Sandbox Code Playgroud)
自定义存储库工厂 bean:
public class MyRepositoryFactoryBean<R extends JpaRepository<T, I>, T, I extends …Run Code Online (Sandbox Code Playgroud) 我是Elasticsearch的新手.我有一个过滤查询如下
{
"query": {
"filtered" : {
"query" : {
"term" : {
"title" : "crime"
}
},
"highlight" : {
"fields" : {
"title" : {}
}
},
"filter" : {
"term" : { "year" : 1961 }
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试此查询并得到错误时:
[filtered] query does not support [highlight]
Run Code Online (Sandbox Code Playgroud)
筛选查询支持突出显示?如果没有,我如何使用过滤器在查询中实现突出显示?我必须使用过滤器.
感谢致敬!
我在我的项目中使用 SQL Server,我必须根据同一个表中的其他行更新某些行的列值。这是我的表:
| Name | Code | Locale
--------------------
| A | ab | en
| A | cd | ar
| A | ef | ru
| B | gh | ar
Run Code Online (Sandbox Code Playgroud)
我需要根据 Locale 为“en”且在 Name 中具有相同值的行的 Code 值更新 Locale 不是“en”的行的 Code 值。保证在 Locale 中带有“en”的每一行在 Name 中都有一个唯一的值。所以这就是我希望实现的目标
| Name | Code | Locale
--------------------
| A | ab | en
| A | ab | ar
| A | ab | ru
| B | gh | ar …Run Code Online (Sandbox Code Playgroud) 我一直在谷歌搜索JTDS(1.3.1)的配置,以便与HikariCP(2.4.3),Spring(4.1.2)和MS SQL Server(2008)一起使用,但无法找到完整且有效的示例.
这是我有的:
<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<constructor-arg ref="hikariConfig" />
</bean>
<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
<property name="poolName" value="springHikariCP" />
<property name="connectionTestQuery" value="SELECT 1" />
<property name="dataSourceClassName" value="${jdbc.dataSourceClassName}" />
<property name="maximumPoolSize" value="${jdbc.maximumPoolSize}" />
<property name="minimumIdle" value="${jdbc.minimumIdle}" />
<property name="idleTimeout" value="${jdbc.idleTimeout}" />
....
<property name="dataSourceProperties">
<props>
....
</props>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
那里的任何人都可以共享生产环境中使用的JTDS配置吗?
问候.
UPDATE
我找到了这个帖子:
似乎JTDS在使用HikariCP时遇到了问题.实际上,我也有这个问题.这是我对JTDS的完整配置:
<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<constructor-arg ref="hikariConfig" />
</bean>
<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
<property name="poolName" value="springHikariCP" />
<property name="connectionTestQuery" value="${jdbc.connectionTestQuery}" />
<property name="dataSourceClassName" value="${jdbc.dataSourceClassName}" />
<property name="maximumPoolSize" value="${jdbc.maximumPoolSize}" …Run Code Online (Sandbox Code Playgroud) 我正在做一个 Spring Web 应用程序。在我的 messages.properties 文件中,有一个一行字符串,如下所示:
label.name.tooltip=The "name" field ...
Run Code Online (Sandbox Code Playgroud)
我的 JSP 文件显示该字符串如下:
<spring:message code="label.name.tooltip" />
Run Code Online (Sandbox Code Playgroud)
然而,显示的文字只是“The”,这意味着“name”中的部分被删掉了。
我不知道为什么会发生这种情况。谷歌搜索,在双引号前添加反斜杠等方法不起作用。
问候和感谢!
更新
整个问题是由我使用 A 标签的 title 属性中的字符串引起的,如下所示:
a href="#" data-toggle="tooltip" title="<spring:message code="label.name.tooltip" />
Run Code Online (Sandbox Code Playgroud)
正如 Bossie 所暗示的,浏览器会删除从双引号开始的字符串内容。
Misha 做了相当多的解释,这帮助我更多地了解该消息是如何运作的。谢谢,米莎!!!
我在 SO 找到了一个解决方案,就我而言,使用“名称”而不是双引号。希望这对其他人有帮助。
asp.net-mvc ×1
hikaricp ×1
html ×1
java ×1
jtds ×1
spring ×1
spring-data ×1
spring-mvc ×1
sql ×1
sql-server ×1
timezone ×1
utf-8 ×1
wysiwyg ×1