Json 简单的Spring/AngularJS休息消费教程赢得';无法获取/显示数据
我完全遵循了这一点,但我似乎无法成功加载JSON内容 以下是我根据教程创建的文件: index.html:Json 简单的Spring/AngularJS休息消费教程赢得';无法获取/显示数据,json,angularjs,spring,rest,groovy,Json,Angularjs,Spring,Rest,Groovy,我完全遵循了这一点,但我似乎无法成功加载JSON内容 以下是我根据教程创建的文件: index.html: <!doctype html> <html ng-app> <head> <title>Hello AngularJS</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.
<!doctype html>
<html ng-app>
<head>
<title>Hello AngularJS</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<script src="hello.js"></script>
</head>
<body>
<div ng-controller="Hello">
<p>The ID is {{greeting.id}}</p>
<p>The content is {{greeting.content}}</p>
</div>
</body>
</html>
app.groovy:
@Controller class JsApp { }
下面是我运行spring run app.groovy命令的输出:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Dev\rest-test>spring run app.groovy
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.2.5.RELEASE)
2015-09-02 22:52:00.032 INFO 1968 --- [ runner-0] o.s.boot.SpringApplicat
ion : Starting application on asbs-dev with PID 1968 (C:\Users\me\.m2\repository\org\springframework\boot\spring-boot\1.2.5.RELEASE\spring-b
oot-1.2.5.RELEASE.jar started by me in C:\Dev\rest-test)
2015-09-02 22:52:00.513 INFO 1968 --- [ runner-0] ationConfigEmbeddedWebA
pplicationContext : Refreshing org.springframework.boot.context.embedded.Annotat
ionConfigEmbeddedWebApplicationContext@1336a56: startup date [Wed Sep 02 22:52:0
0 EDT 2015]; root of context hierarchy
2015-09-02 22:52:03.049 INFO 1968 --- [ runner-0] o.s.b.f.s.DefaultListab
leBeanFactory : Overriding bean definition for bean 'beanNameViewResolver':
replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; auto
wireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBea
nName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$White
labelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodN
ame=null; destroyMethodName=(inferred); defined in class path resource [org/spri
ngframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorView
Configuration.class]] with [Root bean: class [null]; scope=; abstract=false; laz
yInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=
false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConf
iguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver
; initMethodName=null; destroyMethodName=(inferred); defined in class path resou
rce [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAu
toConfigurationAdapter.class]]
2015-09-02 22:52:05.578 INFO 1968 --- [ runner-0] s.b.c.e.t.TomcatEmbedde
dServletContainer : Tomcat initialized with port(s): 8080 (http)
2015-09-02 22:52:05.983 INFO 1968 --- [ runner-0] o.apache.catalina.core.
StandardService : Starting service Tomcat
2015-09-02 22:52:05.987 INFO 1968 --- [ runner-0] org.apache.catalina.cor
e.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.23
2015-09-02 22:52:06.200 INFO 1968 --- [ost-startStop-1] org.apache.catalina.loa
der.WebappLoader : Unknown loader org.springframework.boot.cli.compiler.Extende
dGroovyClassLoader$DefaultScopeParentClassLoader@1adac6c class org.springframewo
rk.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader
2015-09-02 22:52:06.279 INFO 1968 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[loc
alhost].[/] : Initializing Spring embedded WebApplicationContext
2015-09-02 22:52:06.279 INFO 1968 --- [ost-startStop-1] o.s.web.context.Context
Loader : Root WebApplicationContext: initialization completed in 5769
ms
2015-09-02 22:52:08.356 INFO 1968 --- [ost-startStop-1] o.s.b.c.e.ServletRegist
rationBean : Mapping servlet: 'dispatcherServlet' to [/]
2015-09-02 22:52:08.370 INFO 1968 --- [ost-startStop-1] o.s.b.c.embedded.Filter
RegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2015-09-02 22:52:08.371 INFO 1968 --- [ost-startStop-1] o.s.b.c.embedded.Filter
RegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2015-09-02 22:52:09.236 INFO 1968 --- [ runner-0] s.w.s.m.m.a.RequestMapp
ingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.cont
ext.embedded.AnnotationConfigEmbeddedWebApplicationContext@1336a56: startup date
[Wed Sep 02 22:52:00 EDT 2015]; root of context hierarchy
2015-09-02 22:52:09.453 INFO 1968 --- [ runner-0] s.w.s.m.m.a.RequestMapp
ingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.Res
ponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframewo
rk.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServ
letRequest)
2015-09-02 22:52:09.455 INFO 1968 --- [ runner-0] s.w.s.m.m.a.RequestMapp
ingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.spr
ingframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web
.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2015-09-02 22:52:09.474 INFO 1968 --- [ runner-0] o.s.w.s.c.a.WebMvcConfi
gurerAdapter : Adding welcome page: file:/C:/Dev/rest-test/public/index.htm
l
2015-09-02 22:52:09.525 INFO 1968 --- [ runner-0] o.s.w.s.handler.SimpleU
rlHandlerMapping : Root mapping to handler of type [class org.springframework.w
eb.servlet.mvc.ParameterizableViewController]
2015-09-02 22:52:09.556 INFO 1968 --- [ runner-0] o.s.w.s.handler.SimpleU
rlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class or
g.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-09-02 22:52:09.557 INFO 1968 --- [ runner-0] o.s.w.s.handler.SimpleU
rlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.spring
framework.web.servlet.resource.ResourceHttpRequestHandler]
2015-09-02 22:52:09.723 INFO 1968 --- [ runner-0] o.s.w.s.handler.SimpleU
rlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [clas
s org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-09-02 22:52:11.165 INFO 1968 --- [ runner-0] o.s.j.e.a.AnnotationMBe
anExporter : Registering beans for JMX exposure on startup
2015-09-02 22:52:11.428 INFO 1968 --- [ runner-0] s.b.c.e.t.TomcatEmbedde
dServletContainer : Tomcat started on port(s): 8080 (http)
2015-09-02 22:52:11.429 INFO 1968 --- [ runner-0] o.s.boot.SpringApplicat
ion : Started application in 12.111 seconds (JVM running for 17.50
4)
2015-09-02 22:52:17.615 INFO 1968 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[loc
alhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2015-09-02 22:52:17.616 INFO 1968 --- [nio-8080-exec-1] o.s.web.servlet.Dispatc
herServlet : FrameworkServlet 'dispatcherServlet': initialization started
2015-09-02 22:52:17.721 INFO 1968 --- [nio-8080-exec-1] o.s.web.servlet.Dispatc
herServlet : FrameworkServlet 'dispatcherServlet': initialization complet
ed in 102 ms
Microsoft Windows[版本6.1.7601]
版权所有(c)2009微软公司。版权所有。
C:\Dev\rest test>spring run app.groovy
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
::弹簧靴::(v1.2.5.版本)
2015-09-02 22:52:00.032信息1968---[runner-0]o.s.boot.SpringApplication
ion:使用PID 1968(C:\Users\me\.m2\repository\org\springframework\boot\spring boot\1.2.5.RELEASE\spring-b)在asbs dev上启动应用程序
oot-1.2.5.RELEASE.jar由我在C:\Dev\rest测试中启动)
2015-09-02 22:52:00.513信息1968---[runner-0]配置嵌入式WebA
ApplicationContext:刷新org.springframework.boot.context.embedded.Annotat
ionConfigEmbeddedWebApplicationContext@1336a56:启动日期[Wed Sep 02 22:52:0]
2015年美国东部夏令时0分];上下文层次结构的根
2015-09-02 22:52:03.049信息1968---[runner-0]o.s.b.f.s.DefaultListab
leBeanFactory:重写bean“beanNameViewResolver”的bean定义:
替换[Root bean:class[null];作用域=;抽象=false;lazyInit=false;自动
wireMode=3;dependencyCheck=0;autowireCandidate=true;primary=false;factoryBea
nName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$White
labelErrorViewConfiguration;factoryMethodName=beanNameViewResolver;initMethodN
ame=null;destroyMethodName=(推断);在类路径资源[org/spri]中定义
ngframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorView
Configuration.class]]和[Root bean:class[null];scope=;abstract=false;laz
yInit=false;autowireMode=3;dependencyCheck=0;autowireCandidate=true;primary=
false;factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConf
配置$WebMvcAutoConfigurationAdapter;factoryMethodName=beanNameViewResolver
;initMethodName=null;destroyMethodName=(推断);在类路径资源中定义
rce[org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAu
ToConfiguration Adapter.class]]
2015-09-02 22:52:05.578信息1968---[runner-0]s.b.c.e.t.TomcatEmbedde
dServletContainer:Tomcat已初始化端口:8080(http)
2015-09-02 22:52:05.983信息1968---[runner-0]o.apache.catalina.core。
标准服务:启动Tomcat服务
2015-09-02 22:52:05.987信息1968---[runner-0]org.apache.catalina.cor
e、 标准引擎:启动Servlet引擎:ApacheTomcat/8.0.23
2015-09-02 22:52:06.200信息1968---[ost-startStop-1]org.apache.catalina.loa
der.WebappLoader:未知加载程序org.springframework.boot.cli.compiler.Extende
dGroovyClassLoader$DefaultScopeParentClassLoader@1adac6c类org.springframewo
rk.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader
2015-09-02 22:52:06.279信息1968---[ost-startStop-1]o.a.c.c.c.[Tomcat].[loc]
alhost].[/]:初始化Spring嵌入式WebApplicationContext
2015-09-02 22:52:06.279信息1968---[ost-startStop-1]o.s.web.context.context
加载程序:根WebApplicationContext:初始化在5769中完成
太太
2015-09-02 22:52:08.356信息1968---[ost-startStop-1]o.s.b.c.e.ServletRegist
rationBean:将servlet:'dispatcherServlet'映射到[/]
2015-09-02 22:52:08.370信息1968---[ost-startStop-1]o.s.b.c.embedded.Filter
RegistrationBean:将筛选器:“characterEncodingFilter”映射到:[/*]
2015-09-02 22:52:08.371信息1968---[ost-startStop-1]o.s.b.c.embedded.Filter
RegistrationBean:将筛选器:“hiddenHttpMethodFilter”映射到:[/*]
2015-09-02 22:52:09.236信息1968---[runner-0]s.w.s.m.m.a.RequestMapp
InHandlerAdapter:正在寻找@ControllerAdvice:org.springframework.boot.cont
外部嵌入。AnnotationConfigEmbeddedWebApplicationContext@1336a56:启动日期
[美国东部时间2015年9月2日星期三22:52:00];上下文层次结构的根
2015-09-02 22:52:09.453信息1968---[runner-0]s.w.s.m.m.a.RequestMapp
InHandlerMapping:将“{[/error]}”映射到public org.springframework.http.Res
ponseEntity org.springframewo
错误(javax.servlet.http.HttpServ
出租人(请求)
2015-09-02 22:52:09.455信息1968---[runner-0]s.w.s.m.m.a.RequestMapp
InHandlerMapping:将“{[/error],products=[text/html]}”映射到public org.spr
ingframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web
.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2015-09-02 22:52:09.474信息1968---[runner-0]o.s.w.s.c.a.WebMvcConfi
guerradapter:添加欢迎页面:文件:/C:/Dev/rest-test/public/index.htm
L
2015-09-02 22:52:09.525信息1968---[runner-0]o.s.w.s.handler.SimpleU
rlHandlerMapping:根映射到[classorg.springframework.w]类型的处理程序
eb.servlet.mvc.ParameterableViewController]
2015-09-02 22:52:09.556信息1968---[runner-0]o.s.w.s.handler.SimpleU
rlHandlerMapping:将URL路径[/webjars/**]映射到[class或
g、 springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-09-02 22:52:09.557信息1968---[runner-0]o.s.w.s.handler.SimpleU
rlHandlerMapping:将URL路径[/**]映射到[class org.spring]类型的处理程序上
framework.web.servlet.resource.ResourceHttpRequestHandler]
2015-09-02 22:52:09.723信息1968---[runner-0]o.s.w.s.handler.SimpleU
rlHandlerMapping:将URL路径[/**/favicon.ico]映射到类型为[clas]的处理程序上
s org.springframework.web.servlet.resource.ResourceHttpRequestHandler
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Dev\rest-test>spring run app.groovy
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.2.5.RELEASE)
2015-09-02 22:52:00.032 INFO 1968 --- [ runner-0] o.s.boot.SpringApplicat
ion : Starting application on asbs-dev with PID 1968 (C:\Users\me\.m2\repository\org\springframework\boot\spring-boot\1.2.5.RELEASE\spring-b
oot-1.2.5.RELEASE.jar started by me in C:\Dev\rest-test)
2015-09-02 22:52:00.513 INFO 1968 --- [ runner-0] ationConfigEmbeddedWebA
pplicationContext : Refreshing org.springframework.boot.context.embedded.Annotat
ionConfigEmbeddedWebApplicationContext@1336a56: startup date [Wed Sep 02 22:52:0
0 EDT 2015]; root of context hierarchy
2015-09-02 22:52:03.049 INFO 1968 --- [ runner-0] o.s.b.f.s.DefaultListab
leBeanFactory : Overriding bean definition for bean 'beanNameViewResolver':
replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; auto
wireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBea
nName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$White
labelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodN
ame=null; destroyMethodName=(inferred); defined in class path resource [org/spri
ngframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorView
Configuration.class]] with [Root bean: class [null]; scope=; abstract=false; laz
yInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=
false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConf
iguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver
; initMethodName=null; destroyMethodName=(inferred); defined in class path resou
rce [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAu
toConfigurationAdapter.class]]
2015-09-02 22:52:05.578 INFO 1968 --- [ runner-0] s.b.c.e.t.TomcatEmbedde
dServletContainer : Tomcat initialized with port(s): 8080 (http)
2015-09-02 22:52:05.983 INFO 1968 --- [ runner-0] o.apache.catalina.core.
StandardService : Starting service Tomcat
2015-09-02 22:52:05.987 INFO 1968 --- [ runner-0] org.apache.catalina.cor
e.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.23
2015-09-02 22:52:06.200 INFO 1968 --- [ost-startStop-1] org.apache.catalina.loa
der.WebappLoader : Unknown loader org.springframework.boot.cli.compiler.Extende
dGroovyClassLoader$DefaultScopeParentClassLoader@1adac6c class org.springframewo
rk.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader
2015-09-02 22:52:06.279 INFO 1968 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[loc
alhost].[/] : Initializing Spring embedded WebApplicationContext
2015-09-02 22:52:06.279 INFO 1968 --- [ost-startStop-1] o.s.web.context.Context
Loader : Root WebApplicationContext: initialization completed in 5769
ms
2015-09-02 22:52:08.356 INFO 1968 --- [ost-startStop-1] o.s.b.c.e.ServletRegist
rationBean : Mapping servlet: 'dispatcherServlet' to [/]
2015-09-02 22:52:08.370 INFO 1968 --- [ost-startStop-1] o.s.b.c.embedded.Filter
RegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2015-09-02 22:52:08.371 INFO 1968 --- [ost-startStop-1] o.s.b.c.embedded.Filter
RegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2015-09-02 22:52:09.236 INFO 1968 --- [ runner-0] s.w.s.m.m.a.RequestMapp
ingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.cont
ext.embedded.AnnotationConfigEmbeddedWebApplicationContext@1336a56: startup date
[Wed Sep 02 22:52:00 EDT 2015]; root of context hierarchy
2015-09-02 22:52:09.453 INFO 1968 --- [ runner-0] s.w.s.m.m.a.RequestMapp
ingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.Res
ponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframewo
rk.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServ
letRequest)
2015-09-02 22:52:09.455 INFO 1968 --- [ runner-0] s.w.s.m.m.a.RequestMapp
ingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.spr
ingframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web
.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2015-09-02 22:52:09.474 INFO 1968 --- [ runner-0] o.s.w.s.c.a.WebMvcConfi
gurerAdapter : Adding welcome page: file:/C:/Dev/rest-test/public/index.htm
l
2015-09-02 22:52:09.525 INFO 1968 --- [ runner-0] o.s.w.s.handler.SimpleU
rlHandlerMapping : Root mapping to handler of type [class org.springframework.w
eb.servlet.mvc.ParameterizableViewController]
2015-09-02 22:52:09.556 INFO 1968 --- [ runner-0] o.s.w.s.handler.SimpleU
rlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class or
g.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-09-02 22:52:09.557 INFO 1968 --- [ runner-0] o.s.w.s.handler.SimpleU
rlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.spring
framework.web.servlet.resource.ResourceHttpRequestHandler]
2015-09-02 22:52:09.723 INFO 1968 --- [ runner-0] o.s.w.s.handler.SimpleU
rlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [clas
s org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-09-02 22:52:11.165 INFO 1968 --- [ runner-0] o.s.j.e.a.AnnotationMBe
anExporter : Registering beans for JMX exposure on startup
2015-09-02 22:52:11.428 INFO 1968 --- [ runner-0] s.b.c.e.t.TomcatEmbedde
dServletContainer : Tomcat started on port(s): 8080 (http)
2015-09-02 22:52:11.429 INFO 1968 --- [ runner-0] o.s.boot.SpringApplicat
ion : Started application in 12.111 seconds (JVM running for 17.50
4)
2015-09-02 22:52:17.615 INFO 1968 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[loc
alhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2015-09-02 22:52:17.616 INFO 1968 --- [nio-8080-exec-1] o.s.web.servlet.Dispatc
herServlet : FrameworkServlet 'dispatcherServlet': initialization started
2015-09-02 22:52:17.721 INFO 1968 --- [nio-8080-exec-1] o.s.web.servlet.Dispatc
herServlet : FrameworkServlet 'dispatcherServlet': initialization complet
ed in 102 ms