我试图获得一个bean对象来使用Spring Security验证用户登录功能:
ApplicationContext context = new ClassPathXmlApplicationContext(
"com/humandevice/drive/fx/util/applicationContext.xml");
authenticationManager = (AuthenticationManager) context
.getBean("authenticationManager");
Run Code Online (Sandbox Code Playgroud)
我applicationContext.xml在下面:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"
xmlns:context="http://www.springframework.org/schema/context">
<context:component-scan base-package="com.humandevice.drive.fx">
<context:include-filter type="regex"
expression="com.humandevice.drive.fx.*" />
</context:component-scan>
<bean id="LoginController" alias="loginController" class="controller.LoginController">
<property name="authenticationManager" ref="authenticationManager" />
<property name="applicationContext" ref="applicationContext" />
</bean>
<bean id="applicationContext" alias="applicationContext"
class="org.springframework.context.ApplicationContext;">
</bean>
<authentication-manager alias="authenticationManager">
<authentication-provider user-service-ref="userService">
<password-encoder ref="bCryptPasswordEncoder" />
</authentication-provider>
</authentication-manager>
</beans>
Run Code Online (Sandbox Code Playgroud)
但我得到这个例外:
Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 64; cvc-elt.1: Cannot find the declaration of element …Run Code Online (Sandbox Code Playgroud) 如何将日期格式从"dd MMM yyyy"转换为"yyyy-MM-dd"?
我知道我必须使用,SimpleDatFormat但它不起作用,也没有任何类似问题的解决方案.
我有一个日期"2015年12月18日",我正在尝试格式化,但我明白了
java.text.ParseException: Unparseable date: "18 Dec 2015"
这是我的代码:
public String parseDate(String d) {
String result = null;
Date dateObject = null;
SimpleDateFormat dateFormatter = new SimpleDateFormat("dd MMM yyyy");
try {
dateObject = dateFormatter.parse(d);
dateFormatter.applyPattern("yyyy-MM-dd");
result = dateFormatter.format(dateObject);
} catch (ParseException e) {
System.out.println(e);
}
return result;
}
Run Code Online (Sandbox Code Playgroud) 我需要使用自定义参数("data"包含路径)发送post请求,并将内容类型设置为text/plain.我查看了大量类似的问题,但没有一个解决方案有帮助.
该方法应列出此目录中的文件.
我的代码是
public List<FileWrapper> getFileList() {
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
map.add("data", "/public/");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.TEXT_PLAIN);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(
map, headers);
String url = "http://192.168.1.51:8080/pi/FilesServlet";
restTemplate.getMessageConverters().add(new FormHttpMessageConverter());
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
String response = restTemplate
.postForObject(url, request, String.class);
List<FileWrapper> list = new ArrayList<>();
for (String part : response.split("\\|")) {
System.out.println("part " + part);
list.add(new FileWrapper(part));
}
return list;
}
Run Code Online (Sandbox Code Playgroud)
这是用javascript编写的等效工作代码:
function getFileList(direction){
$("div.file-list").html("<center><progress></progress></center>");
$.ajax({
url: "http://192.168.1.51:8080/pi/FilesServlet",
type: "POST",
data: direction ,
contentType: …Run Code Online (Sandbox Code Playgroud) 我写了一个简单的程序来监控我的ping.我目前正在使用NumberAxis自动量程,并且在每次ping之后,我在最后添加新数据,删除第一个并totalCount为X轴位置增加变量.
我想要X轴标签:
4m 35s这两个中的任何一个(最好是第一个)是否可以实现?我想我必须使用CategoryAxis这个,但我不知道如何创建无限数量的类别,并选择只显示完整的分钟.是否可以保持NumberAxis更容易使用传入数据,只需更改标签文本格式?我已经有了一个将秒转换为00h 00m 00s格式的方法.
另外一件事,我认为与自动量程相关,图表在每次输入后都不刷新,但只有一次超过给定范围的10%.因此对于图片中的1000范围,它将绘制100个新的ping,然后将所有100个位置向左移动.只需1次ping就能以某种方式改变它吗?
不确定是否相关,但我会发布代码:
调节器
public class GuiController implements Initializable {
@FXML
Button startButton, stopButton;
@FXML
TextField sField, nField, ipField;
@FXML
LineChart<Integer, Integer> chart;
@FXML
Label timeLabel, pingLabel;
ScheduledService<Integer> scheduler;
ObservableList<Data<Integer, Integer>> data;
public static int totalCount = 0;
private String getTime(double seconds) {
int h = (int) (seconds / 3600);
int m = (int) ((seconds % 3600) / 60);
int s = …Run Code Online (Sandbox Code Playgroud) 我有一个列表用户朋友的表视图,我需要每隔5秒用我从数据库中检索的数据更新它.
这是我使用的代码:
Main.java
private List<Friend> userFriends;
Run Code Online (Sandbox Code Playgroud)
fx控制器:
ObservableList<FriendWrapper> friendList = FXCollections.observableList(
new ArrayList<FriendWrapper>());
private void updateFriendList() {
new Thread(new Runnable() {
public void run() {
while (Params.loggedUser != null) {
Main.setUserFriends(Params.dao.listUserFriends(Params.loggedUser));
friendList.clear();
for (Friend friend : Main.getUserFriends()) {
friendList.add(new FriendWrapper(friend.getFriendName(), friend.getOnline(), friend.getFriendId(), friend.getWelcomeMessage()));
}
Params.dao.updateOnlineStatus(Params.loggedUser, 3);
try {
Thread.sleep(1000 * 5);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}, "updateFriendList").start();
}
Run Code Online (Sandbox Code Playgroud)
Friend是数据库模型.FriendWrapper是用于表行的对象.
但是我IllegalStateException: Not on FX application thread上线了friendList.clear();
如何从后台运行的线程更改TableView的项目?