将表单发布回控制器时,我遇到了很多困难,控制器应该只包含用户可以编辑的对象的arraylist.
表单正确加载,但是当它发布时,它似乎永远不会发布任何内容.
这是我的表格:
<form action="#" th:action="@{/query/submitQuery}" th:object="${clientList}" method="post">
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Select</th>
<th>Client ID</th>
<th>IP Addresss</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr th:each="currentClient, stat : ${clientList}">
<td><input type="checkbox" th:checked="${currentClient.selected}" /></td>
<td th:text="${currentClient.getClientID()}" ></td>
<td th:text="${currentClient.getIpAddress()}"></td>
<td th:text="${currentClient.getDescription()}" ></td>
</tr>
</tbody>
</table>
<button type="submit" value="submit" class="btn btn-success">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud)
以上工作正常,它正确加载列表.但是,当我POST时,它返回一个空对象(大小为0).我相信这是由于缺乏th:field
,但无论如何这里是控制器POST方法:
...
private List<ClientWithSelection> allClientsWithSelection = new ArrayList<ClientWithSelection>();
//GET method
...
model.addAttribute("clientList", allClientsWithSelection)
....
//POST method
@RequestMapping(value="/submitQuery", method = RequestMethod.POST)
public String processQuery(@ModelAttribute(value="clientList") ArrayList clientList, Model model){
//clientList== …
Run Code Online (Sandbox Code Playgroud) 我已经看了很多资源,包括这个,这个和这个,但是我还没有达到预期的效果.
我要做的就是验证用户身份(使用firebase)然后进行身份验证后,加载他们的配置文件并将其存储在变量中,userProfile
然后再加载下一页Dashboard:
我的登录服务:
public signinUser(user: User) {
this.af.auth.login({
email: user.email,
password: user.password
},
{
provider: AuthProviders.Password,
method: AuthMethods.Password
}
)
.then(
success => {
console.log('Authenticated');
this.getProfile().subscribe( // PROBLEM is here
profile => {
console.log(profile);
console.log('Profile Loaded');
this.router.navigate(['/dashboard']);
}
)
}
)
.catch(function (error) {
...
console.log('ERROR SIGNING USER IN');
}
Run Code Online (Sandbox Code Playgroud)
我的getProfile()
方法:
public getProfile(): Observable<any> {
return this.af.database.object('/profiles/' + this.user.uid)
.flatMap(
profile => {
console.log('inside success');
console.log(profile);
this.userProfile = <User>profile;
console.log('getProfile …
Run Code Online (Sandbox Code Playgroud) 我正在尝试测试我的webcrawler的性能(就执行时间而言),但由于多线程发生,我无法计时.
我的主要课程:
class WebCrawlerTest {
//methods and variables etc
WebCrawlerTest(List<String> websites){
//
}
if(!started){
startTime = System.currentTimeMillis();
executor = Executors.newFixedThreadPool(32); //this is the value I'm tweaking
started=true;
}
for(String site : websites){
executor.submit(webProcessor = new AllWebsiteProcessorTest(site, deepSearch));
}
executor.shutdown();
//tried grabbing end time here with no luck
Run Code Online (Sandbox Code Playgroud)
AllWebsiteProcessorTest类:
class AllWebsiteProcessorTest implements Runnable{
//methods and var etc
AllWebsiteProcessorTest(String site, boolean deepSearch) {
}
public void run() {
scanSingleWebsite(websites);
for(String email:emails){
System.out.print(email + ", ");
}
private void scanSingleWebsite(String website){
try { …
Run Code Online (Sandbox Code Playgroud) 我花了好几个小时试图让服务器运行(第一次),尝试在线发布的许多解决方案,但没有成功.
首次安装(Win 7 x64),灯仍然是orage(服务器脱机).如果我查看服务,启动/恢复服务仍为绿色:
如果我进入服务并尝试启动wampmysqld64
服务,我收到此错误消息:
这是事件查看器应用程序日志(WAMP mysql日志为空):
Error 11/09/2015 09:04:22 MySQL 100 None Aborting
Error 11/09/2015 09:04:22 MySQL 100 None Unknown/unsupported storage engine: InnoDB
Error 11/09/2015 09:04:22 MySQL 100 None Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
Error 11/09/2015 09:04:22 MySQL 100 None Plugin 'InnoDB' init function returned error.
Error 11/09/2015 09:04:22 MySQL 100 None InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and …
Run Code Online (Sandbox Code Playgroud) 我正在阅读此处的 NG2 教程,但遇到了障碍。
\n\n当我尝试将我的文件导入AppRoutingModule
到我的文件中时app.module.ts
,出现“ Cannot find module \'./app-routing.module
\”错误。我在这里看到了这篇文章以及其他解决方案,但它们似乎都与 相关systemjs
,但不相关 webpack
。
这是我的package.json:
\n\n{\n "name": "heroes",\n "version": "0.0.0",\n "license": "MIT",\n "angular-cli": {},\n "scripts": {\n "start": "ng serve",\n "lint": "tslint \\"src/**/*.ts\\"",\n "test": "ng test",\n "pree2e": "webdriver-manager update",\n "e2e": "protractor"\n },\n "private": true,\n "dependencies": {\n "@angular/common": "2.0.0",\n "@angular/compiler": "2.0.0",\n "@angular/core": "2.0.0",\n "@angular/forms": "2.0.0",\n "@angular/http": "2.0.0",\n "@angular/platform-browser": "2.0.0",\n "@angular/platform-browser-dynamic": "2.0.0",\n "@angular/router": "3.0.0",\n "angular2-in-memory-web-api": "0.0.21",\n "core-js": "^2.4.1",\n "rxjs": …
Run Code Online (Sandbox Code Playgroud) 好的,我正在使用百里香页面布局.
它似乎工作正常,但是,我想知道如何<title></title>
在<head></head>
使用片段的页面中配置属性?目前,头部中的所有内容都被标题片段覆盖(可以在下面看到).
这是我的: resources/templates/fragments/header.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:fragment="header">
<link href="../../static/css/bootstrap.min.css" th:href="@{css/bootstrap.min.css}" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" th:src="@{js/bootstrap.min.js}"></script>
</head>
<body></body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我的索引页面(我希望显示标题标签):
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:include="fragments/header :: header">
<title>THIS DOES NOT SHOW</title>
</head>
<body>
<div class="container">
<div th:include="fragments/headerNavbar :: headerNavbar"></div>
<h1>hey</h1>
<div class="btn btn-success">button</div>
<button class="btn btn-success">another</button>
</div>
Run Code Online (Sandbox Code Playgroud)
这是实际的HTML输出:
<head>
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="js/bootstrap.min.js"></script>
</head>
Run Code Online (Sandbox Code Playgroud)
我知道发生了什么.头文件片段被加载(包含)到我的索引页面的头部,因此它覆盖了所有属性.
我的问题是我不知道如何有一个标题片段并且在指定属性时让文件使用该片段,如标题.
这是我在索引文件中尝试过的:
<head>
<div th:include="fragments/header :: header"></div>
<title>THIS DOES NOT SHOW</title>
</head> …
Run Code Online (Sandbox Code Playgroud) 在我的主要课程中,我有: List<Person> allPeople = new ArrayList<>();
然后在类中我有一个方法,它返回所有人的String数组Id
(Person有一个访问器方法getId()
).
将列表转换为只有Ids为String的数组的最漂亮的方法是什么?
这是我目前的解决方案:
public String[] getAllId() {
Object[] allPeopleArray = allPeople.toArray();
String allId[] = new String[allPeople.size()];
for(int i=0; i<=allPeople.size()-1; i++){
allId[i] = ((Person)allPeopleArray [i]).getId();
}
return allId;
}
Run Code Online (Sandbox Code Playgroud)
以上是有效的,但有没有"更好"的方法呢?
java ×4
angular ×2
spring-boot ×2
spring-mvc ×2
thymeleaf ×2
angular-cli ×1
angularjs ×1
asynchronous ×1
callback ×1
chaining ×1
innodb ×1
mysql ×1
observable ×1
spring ×1
wamp ×1