我想使用Java代码获取不同时区的本地时间.根据传递给函数的时区,我需要该时区的本地时间.怎么做到这一点?
使用Tomcat 6.0.x,我们可以使用Http11NioProtocol并获得可扩展的性能.使用Http11NioProtocol是否有任何特定的原因/缺点,Tomcat没有使用此协议作为默认协议?
这个小型JavaFX测试应用程序
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class ApplicationWithNonResizableStage extends Application {
public static void main(final String[] args) {
launch(args);
}
@Override
public void start(final Stage primaryStage) throws Exception {
final Rectangle rectangle = new Rectangle(200, 100, Color.POWDERBLUE);
final BorderPane pane = new BorderPane(rectangle);
final Scene scene = new Scene(pane);
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.show();
}
}
Run Code Online (Sandbox Code Playgroud)
产生一个不需要的填充窗口:

删除呼叫primaryStage.setResizable(false)也会删除效果:

出了什么问题?
是否可以添加一个ArrayList键作为HashMap.我想保留双字母的频率数.二元组是关键,价值就是它的频率.
对于像"他是"这样的每个双子星,我创建一个ArrayListfor it并将其插入到HashMap.但我没有得到正确的输出.
public HashMap<ArrayList<String>, Integer> getBigramMap(String word1, String word2) {
HashMap<ArrayList<String>, Integer> hm = new HashMap<ArrayList<String>, Integer>();
ArrayList<String> arrList1 = new ArrayList<String>();
arrList1 = getBigram(word1, word2);
if (hm.get(arrList1) != null) {
hm.put(arrList1, hm.get(arrList1) + 1);
} else {
hm.put(arrList1, 1);
}
System.out.println(hm.get(arrList1));
return hm;
}
public ArrayList<String> getBigram(String word1, String word2) {
ArrayList<String> arrList2 = new ArrayList<String>();
arrList2.add(word1);
arrList2.add(word2);
return arrList2;
}
Run Code Online (Sandbox Code Playgroud) 我正在使用LibGDX开发Android游戏.菜单屏幕中有4个按钮,但ClickListener这些按钮不起作用.
// retrieve the custom skin for our 2D widgets
Skin skin = super.getSkin();
// create the table actor and add it to the stage
table = new Table( skin );
table.width = stage.width();
table.height = stage.height();
stage.addActor( table );
// retrieve the table's layout
TableLayout layout = table.getTableLayout();
// register the button "start game"
TextButton startGameButton = new TextButton( "Start game", skin );
startGameButton.addListener( new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) { …Run Code Online (Sandbox Code Playgroud) 我喜欢将应用程序模块化到容器中的想法(db,fronted,backing ...)但是,根据Docker文档,"Compose非常适合开发,测试和登台环境".这句话对生产环境一无所知.因此,我在这里感到困惑.
是否更好地Dockerfile从头开始构建生产映像并在那里安装所有LAMP堆栈(等)?或者用更好的方式构建生产环境docker-compose.yml?是否有任何理由(开销,链接等)Docker没有明确说出Compose对于生产来说很棒?
根据MySQL手册,表注释限制为60个字符.我正在设计MySQL Workbench中的模式,它没有强制实施此限制,因此我最终经常编写超过60个符号,这导致SQL脚本失败.说实话,我很满意我的架构内部的表注释(即不导出到实际的数据库),但Workbench也不允许这样做.因此我的问题是:有没有办法将MySQL中表注释的最大长度增加到255?
我在p:autoComplete我的项目的搜索表单中使用PrimeFaces 小部件.用户可以选择他想要包含多少和哪些表单元素(搜索参数),因此我需要completeMethod为每个元素传递一个ID .我已经尝试添加onfocus=".."将对象传递给bean,但只有在首次加载元素时才会激活它.
我的问题:如何将属性传递给completeMethod?
元素的XHTML(简单):
<p:autoComplete value="#{filter.value}" label="dynamic search attribute"
completeMethod="#{myBean.complete}" />
Run Code Online (Sandbox Code Playgroud)
豆(简单):
@Named("myBean")
public class MyController implements Serializable {
public List<String> complete(String query) {
List<String> results = new ArrayList<String>();
// ... code
return results;
}
}
Run Code Online (Sandbox Code Playgroud)
从理论上讲,这似乎是完美的解决方案:
<p:autoComplete value="#{filter.value}" label="dynamic search attribute"
completeMethod="#{myBean.complete(filter)}" />
Run Code Online (Sandbox Code Playgroud)
又来了豆子:
@Named("myBean")
public class MyController implements Serializable {
public List<String> complete(String query, FilterObject o) {
List<String> results = new ArrayList<String>();
// ... database query based on FilterObject …Run Code Online (Sandbox Code Playgroud) 每次用户点击单选按钮时,我都会尝试显示验证消息.
这仅在我单击提交按钮时有效,但在单击单选按钮时不起作用:
<h:form id="form">
<p:panel id="panel">
<ui:repeat value="#{questionsBean}" var="question">
<h:panelGrid columns="3" style="margin-bottom:10px" cellpadding="5">
<h:outputText value="#{question.questionText}" />
<p:selectOneRadio id="question" value="#{question.response}"
validator="#{question.validate}" required="true">
<f:selectItem itemLabel="Yes" itemValue="Yes" />
<f:selectItem itemLabel="No" itemValue="No" />
<p:ajax update="msgQuestion" event="change"/>
</p:selectOneRadio>
<p:message for="question" id="msgQuestion" />
</h:panelGrid>
</ui:repeat>
<p:commandButton id="btn" value="Save" update="panel" partialSubmit="true"/>
</p:panel>
</h:form>
Run Code Online (Sandbox Code Playgroud) 为了开发JavaFX应用程序,我使用了eclipse的4.3.1快照和JDK 8 build b116.在我的工作区项目中,构建路径中的JRE库包含始终重置为Java 1.4:

不幸的是,这只能暂时修复(直到下一次eclipse重启):

在我的pom文件的构建部分,我有:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<debug>true</debug>
<debuglevel>source,lines</debuglevel>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我很欣赏一个不太灵活的解决方案.
[更新]这个问题似乎与当前版本的问题有关