我有一个包含TextArea的简单UiBinder小部件:
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:TextArea visibleLines="3" />
</ui:UiBinder>
Run Code Online (Sandbox Code Playgroud)
我想控制此textarea的背景颜色,以便进行可写和只读状态.GWT使用"-readonly"样式名称装饰器来实现此目的.所以我试试这个:
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:style>
.textBoxStyle {
background-color:yellow;
}
.textBoxStyle-readonly {
background-color:lightgray;
}
</ui:style>
<g:TextArea styleName="{style.textBoxStyle}" visibleLines="3" />
</ui:UiBinder>
Run Code Online (Sandbox Code Playgroud)
显然这不起作用,因为样式名称被混淆为CssResources导致类似这样的事情:
.G1x26wpeN {
background-color:yellow
}
.G1x26wpeO {
background-color: lightgray;
}
Run Code Online (Sandbox Code Playgroud)
可写textarea的结果HTML如下所示:
<textarea tabindex="0" class="G1x26wpeN" rows="3"/>
Run Code Online (Sandbox Code Playgroud)
只读textarea看起来像这样:
<textarea tabindex="0" class="G1x26wpeN G1x26wpeN-readonly" readonly="" rows="3"/>
Run Code Online (Sandbox Code Playgroud)
如何声明样式,以便GWT对主要部分进行模糊处理而不对"-readonly"decdorator进行模糊处理?
我知道我可以禁用整个样式名称的混淆.但我想在使用装饰器的同时保持混淆.
我想用Java中的ehcache做一些我认为应该非常简单的事情,但是我花了足够的时间来挫败自己的文档......
将值写入磁盘永久缓存.关掉.
再次启动并读取该值.
这是我的Java函数:
private static void testCacheWrite() {
// create the cache manager from our configuration
URL url = TestBed.class.getClass().getResource("/resource/ehcache.xml");
CacheManager manager = CacheManager.create(url);
// check to see if our cache exits, if it doesn't create it
Cache testCache = null;
if (!manager.cacheExists("test")) {
System.out.println("No cache found. Creating cache...");
int maxElements = 50000;
testCache = new Cache("test", maxElements,
MemoryStoreEvictionPolicy.LFU, true, null, true, 60, 30,
true, Cache.DEFAULT_EXPIRY_THREAD_INTERVAL_SECONDS, null);
manager.addCache(testCache);
// add an element to persist
Element el = new Element("key", …Run Code Online (Sandbox Code Playgroud) 有一个Checkstyle规则DesignForExtension.它说:如果你有一个公共/受保护的方法,它不是抽象的,也不是最终的也不是空的,它不是"为扩展而设计的".请在Checkstyle页面上阅读此规则的说明以获取基本原理.
想象一下这个案子.我有一个抽象类,它定义了一些字段和这些字段的验证方法:
public abstract class Plant {
private String roots;
private String trunk;
// setters go here
protected void validate() {
if (roots == null) throw new IllegalArgumentException("No roots!");
if (trunk == null) throw new IllegalArgumentException("No trunk!");
}
public abstract void grow();
}
Run Code Online (Sandbox Code Playgroud)
我还有一个植物的子类:
public class Tree extends Plant {
private List<String> leaves;
// setters go here
@Overrides
protected void validate() {
super.validate();
if (leaves == null) throw new IllegalArgumentException("No …Run Code Online (Sandbox Code Playgroud) 当我尝试通过alter命令更改表中列的数据类型时...
alter table temp alter column id type bigserial;
Run Code Online (Sandbox Code Playgroud)
我明白了
ERROR: type "bigserial" does not exist
Run Code Online (Sandbox Code Playgroud)
如何将数据类型从bigint更改为bigserial?
一直在考虑使用Docker进行REST服务项目.我有一个问题是我们是否可以使用Docker在同一主机/端口上运行多个版本的服务.
例如,我想在{myserver}:8080/v1 /和另一个{myserver}:8080/v2 /.
如果它完全相关,那么这些将是基于Java:8的Docker镜像,在Spring Boot REST框架上使用java jar构建.
Docker容器可以实现吗?
我必须替换GWT中现有url的协议部分.该java.net软件包有一个专门为此目的构建的类:URL.遗憾的是,GWT 不会模拟java.net包.
如何在不创建自己的解析器的情况下在GWT中重新组合URL?(我知道UrlBuilder,但UrlBuilder不会使用现有的URL)
示例:我在字符串" http://myserver.com/somepath/file.html?param "中有一个url,我想用"https"替换协议部分.
一个简单的HTML文件:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<form method="POST" action="test.jsp" accept-charset="utf-8" method="post" enctype="application/x-www-form-urlencoded" >
<input type="text" name="P"/>
<input type="submit" value="subMit"/>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
HTML文件由服务器使用标头提供Content-Type:text/html; charset=utf-8.一切都说:"亲爱的浏览器,当你发布这个表格,请发布utf-8编码".浏览器实际上是这样做的.输入字段中输入的每个值都将采用UTF-8编码.但是浏览器不会告诉服务器这个!post请求的HTTP头将包含一个Content-Type:application/x-www-form-urlencoded字段,但字符集将被省略(使用FF3.6和IE8测试).
问题是我使用的应用程序服务器(Tomcat6)期望Content-Type标头中的字符集(如RFC2388中所述).像这样:Content-Type:application/x-www-form-urlencoded;charset=utf-8.如果省略字符集,它将采用ISO-8859-1,它不是用于编码的字符集.结果是数据损坏.
是否有人知道如何强制当前浏览器将charset附加到Content-Type标头?
我有一个大约1500万条目的大文件.文件中的每一行都包含一个字符串(称之为键).
我需要使用java在文件中找到重复的条目.我尝试使用散列图并检测重复的条目.显然这种方法给我一个"java.lang.OutOfMemoryError:Java堆空间"错误.
我怎么解决这个问题?
我想我可以增加堆空间并尝试它,但我想知道是否有更好的有效解决方案而不必调整堆空间.
我想发送邮件而不用打扰用于传递的SMTP服务器.
所以JavaMail API对我不起作用,因为我必须指定要连接的SMTP服务器.
我希望图书馆通过查询邮件地址域的MX记录,自行查找哪个SMTP服务器负责哪个电子邮件地址.
我正在寻找像阿司匹林这样的东西.不幸的是我不能使用Aspirin本身,因为开发已经停止了2004,并且库无法正确地与现代垃圾邮件强化服务器通信.
詹姆斯的可嵌入版本可以完成任务.但我还没有找到关于这是否可行的文件.
或者有没有人知道我可以使用的其他库?
我昨天注意到一些非常奇怪的事情.似乎两个线程正在进入同时锁定在同一对象上的两个同步块.
MyClass包含相关代码的class()看起来类似于:
private static int[] myLock = new int[0];
protected static int methodA(final long handle, final byte[] sort) {
synchronized (myLock) {
return xsMethodA(handle, sort);
}
}
protected static int methodB(final long handle) {
synchronized (myLock) {
return xsMethodB(handle);
}
}
Run Code Online (Sandbox Code Playgroud)
我创建了一个运行上面类的应用程序的线程转储,当我看到这个时非常惊讶:
"http-8080-136" daemon prio=10 tid=0x00000000447df000 nid=0x70ed waiting for monitor entry [0x00007fd862aea000]
java.lang.Thread.State: BLOCKED (on object monitor)
at com.MyClass.methodA(MyClass.java:750)
- locked <0x00007fd8a6b8c790> (a [I)
at com.SomeOtherClass.otherMethod(SomeOtherClass.java:226)
...
"http-8080-111" daemon prio=10 tid=0x00007fd87d1a0000 nid=0x70c8 waiting for monitor entry [0x00007fd86e15f000]
java.lang.Thread.State: BLOCKED …Run Code Online (Sandbox Code Playgroud) java ×4
gwt ×2
persistence ×2
algorithm ×1
class-design ×1
concurrency ×1
content-type ×1
css ×1
database ×1
docker ×1
ehcache ×1
ehcache-2 ×1
email ×1
forms ×1
gwt2 ×1
inheritance ×1
james ×1
obfuscation ×1
port ×1
post ×1
postgresql ×1
smtp ×1
sql ×1
synchronized ×1
tomcat ×1
uibinder ×1
url ×1