我想用一个控制器创建简单的hello world应用程序.没有任何类的普通弹簧工作,但是当我添加一个控制器,更改xml文件(按照分步教程),并尝试打开localhost/project/hello.html时,它会抛出404错误.
package com.beingjavaguys.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class HomeController {
@RequestMapping("/hello")
public ModelAndView test() {
String message = "Welcome to Spring 4.0 !";
return new ModelAndView("hello", "message", message);
}
}
Run Code Online (Sandbox Code Playgroud)
web.xml中:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>redirect.jsp</welcome-file>
</welcome-file-list>
</web-app>
Run Code Online (Sandbox Code Playgroud)
调度员servlet.xml中:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans …Run Code Online (Sandbox Code Playgroud) 我已经有一个包含几个分支的现有存储库.现在我必须使用源树在这里初始化git流.但是,当我点击"git flow"按钮,并尝试初始化git流时,我收到以下错误:
sh.exe C:\Users\Foo\AppData\Local\Atlassian\SourceTree\gitflow_local\gitflow\git-flow init -d
fatal: Working tree contains unstaged changes. Aborting.
Completed with errors, see above.
Run Code Online (Sandbox Code Playgroud)
我在每个分支上都使用git pull和git push,没有任何未经修改的变化......出了什么问题?
另外,不会在现有repo上使用git flow命令删除任何文件?
我正在使用loopback 3构建REST服务,我想使用async/await而不是必须使用回调.所以不要这样做:
MyModel.myFunction = (callback) => {
MyModel.find({where: {id: 2}}, (e, data) => {
if (e) return callback(e);
callback(null, data);
});
};
Run Code Online (Sandbox Code Playgroud)
我更喜欢这样做:
MyModel.myFunction = async (callback) => {
try {
const data = await MyModel.find({where: {id: 2}});
callback(null, data);
} catch (e) {
console.error(e);
callback(e);
}
};
Run Code Online (Sandbox Code Playgroud)
回调方法完美无缺 - async/await会产生很多错误:
UnhandledPromiseRejectionWarning: Error: Callback was already called.UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by …我有一个数组数组,用于保存图中节点之间的父子关系。每个嵌套数组的形式都是
array( 0 => parent_node_id, 1 => child_node_id )
Run Code Online (Sandbox Code Playgroud)
所以在这个数组中:
0 => array(
0 => 1
1 => 3
)
Run Code Online (Sandbox Code Playgroud)
两个节点分别为1和3,节点1和节点3之间存在父子关系(外层数组索引0无关)。
1 => array(
0 => 3
1 => 5
),
Run Code Online (Sandbox Code Playgroud)
表示节点 3 和节点 5 之间的父子关系(1不相关)。
这里是父子关系数组(注意外层数组的数组索引(0、1、2、3等)不代表任何东西):
0 => array(
0 => 1
1 => 3
),
1 => array(
0 => 3
1 => 5
),
2 => array(
0 => 3
1 => 7
),
3 => array(
0 => 3
1 => 9 …Run Code Online (Sandbox Code Playgroud) 我正在基于数据库在控制器中创建一个大数组.然后在树枝上我展示它.问题是,有时,随机,这个数组似乎被洗牌.刷新页面后,这是正常的,但是它再次被洗牌,在正常情况下没有模式.
控制器中的PHP数组看起来不错,没有问题.然后我将它传递给模板:
return $this->render('AcmeBundle:FooController:bar.html.twig', [
'allResults' => $results
]);
Run Code Online (Sandbox Code Playgroud)
然后在twig模板中显示它:
{% for r in allResults %}
{{ r.id }} {{ r.name }}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
现在发生的是它有时会导致页面看起来像这样:

我在twig模板中创建了dump来查看数组本身的样子,我得到了:
array (size=437) 'karmv>
psa' => array (size=4) ;">
'id' => string 'karmv>
psa' (length=13) ;">
'pid' => string 'lias="drapa v>zwierzat' (length=22) ;">
'pr" uct_count' => string '1' (length=1) ;">
'popularity' => string '766' (length=3) 'wor dgimna => array (size=4) ;">
'id' => string 'wor dgimna (length=18) ;">
'pid' => string 'y-ertcol-md-3" s' (length=16) …Run Code Online (Sandbox Code Playgroud) 我的项目中有两个完全不同的布局 - 它们都是两个独立的父路由,内部有许多嵌套组件。我想为它们使用单独的全局样式。问题是当我在其中一个导入样式时,另一个也会受到影响:
<style type="scss">
@import "sass/first.scss";
</style>
Run Code Online (Sandbox Code Playgroud)
因为导入是全局的,它会影响其他布局中的类。解决方案是范围样式:
<style type="scss" scoped>
@import "sass/first.scss";
</style>
Run Code Online (Sandbox Code Playgroud)
但它不会影响所有的子元素,只会影响它们的父元素,因此它也不会按预期工作。有没有办法在应用程序中使用像这样的单独的全局样式vue.js?
当我试图通过亚马逊发送电子邮件时,我收到以下错误:
554 Message rejected: Sending suspended for this account. For more information, please check the inbox of the email address associated with your AWS account.
Run Code Online (Sandbox Code Playgroud)
它发生在几天前,与端点有关eu-west-1.有什么不对?
我正在尝试在Windows上安装composer(symfony 2项目).问题是我总是遇到一些错误 - 一些文件不在允许的路径中.
我尝试了几种安装compsoer的方法:
怎么了?
我创建了一个这样的多图:
private ListMultimap<String, int[]> terrainMap = ArrayListMultimap.create();
{
terrainMap.put("Terrain.Ground", new int[] {0,100,300,0});
terrainMap.put("Terrain.Ground", new int[] {300,200,400,0});
terrainMap.put("Terrain.Ground", new int[] {400,250,800,0});
terrainMap.put("Terrain.Ground", new int[] {800,500,810,0});
terrainMap.put("Terrain.DestroyableBlock", new int[] {100,200,150,150});
terrainMap.put("Terrain.DestroyableBlock", new int[] {500,400,600,350});
};
Run Code Online (Sandbox Code Playgroud)
我想以这个特定的顺序显示它,但是当我使用foreach循环时:
for(Map.Entry<String, int[]> entry : terrainMap.entries())
{
System.out.println(entry.getKey());
}
Run Code Online (Sandbox Code Playgroud)
我得到以下结果:
Terrain.DestroyableBlock
Terrain.DestroyableBlock
Terrain.Ground
Terrain.Ground
Terrain.Ground
Terrain.Ground
Run Code Online (Sandbox Code Playgroud)
就像它在地图中按字母顺序自动排序键一样.我可以把它关掉吗?
当我在服务器上输入文件夹并输入git branchcommand时,我看到以下结果:
*develop
something_else
master
Run Code Online (Sandbox Code Playgroud)
但是当我在bitbucket上进入我的存储库时,我发现分支开发并不存在.而是开发分支.sourcetree中的相同内容.
怎么了?
我有以下字符串:
{"key1":"value1","key2":"value2","key3":"value3"}
Run Code Online (Sandbox Code Playgroud)
我想把它转换成这个:
{key1:"value1",key2:"value2",key3:"value3"}
Run Code Online (Sandbox Code Playgroud)
所以我做了这样的事情:
var output = str.replace(/"(.*?)":/, "$1:");
Run Code Online (Sandbox Code Playgroud)
这样我得到:
{key1:"value1","key2":"value2","key3":"value3"}
Run Code Online (Sandbox Code Playgroud)
所以它适用于第一个键,但不适用于其他键.如何使用replace方法替换我在此处显示的所有实例?
javascript ×4
arrays ×2
git ×2
java ×2
php ×2
symfony ×2
amazon-ses ×1
async-await ×1
composer-php ×1
css ×1
ecmascript-6 ×1
github ×1
guava ×1
loopbackjs ×1
node.js ×1
regex ×1
sass ×1
spring-mvc ×1
twig ×1
vue.js ×1
xml ×1