我有一个Spring Boot(v1.3.6)单页面应用程序(angular2),我想将所有请求转发给index.html.
对http:// localhost:8080/index.html的请求正在运行(200,我得到index.html),但http:// localhost:8080/home不是(404).
Runner.class
@SpringBootApplication
@ComponentScan({"packagea.packageb"})
@EnableAutoConfiguration
public class Runner {
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext run = SpringApplication.run(Runner.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
WebAppConfig.class
@Configuration
@EnableScheduling
@EnableAsync
public class WebAppConfig extends WebMvcConfigurationSupport {
private static final int CACHE_PERIOD_ONE_YEAR = 31536000;
private static final int CACHE_PERIOD_NO_CACHE = 0;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.setOrder(-1);
registry.addResourceHandler("/styles.css").addResourceLocations("/styles.css").setCachePeriod(CACHE_PERIOD_ONE_YEAR);
registry.addResourceHandler("/app/third-party/**").addResourceLocations("/node_modules/").setCachePeriod(CACHE_PERIOD_ONE_YEAR);
registry.addResourceHandler("/app/**").addResourceLocations("/app/").setCachePeriod(CACHE_PERIOD_NO_CACHE);
registry.addResourceHandler("/systemjs.config.js").addResourceLocations("/systemjs.config.js").setCachePeriod(CACHE_PERIOD_NO_CACHE);
registry.addResourceHandler("/**").addResourceLocations("/index.html").setCachePeriod(CACHE_PERIOD_NO_CACHE);
}
}
Run Code Online (Sandbox Code Playgroud)
styles.css,, /app/third-party/xyz/xyz.js...正在工作(200,我得到正确的文件).只是/**为了index.html不工作.
所以我已经为我的系统安装了角度,角度材料,角度咏叹调,角度动画依赖性.我只是想测试一下这种即将到来的造型方法.好像我一开始就陷入困境.你能告诉我代码有什么问题吗?
这些是我的3个文件.
我的输出是{{title1}},位于网页的中心位置.
angular.module('MyApp', ['ngMaterial'])
.controller("MyController", function($scope) {
$scope.title1 = 'Lol';
});Run Code Online (Sandbox Code Playgroud)
.buttondemoBasicUsage section {
background: #f7f7f7;
border-radius: 3px;
text-align: center;
margin: 1em;
position: relative !important;
padding-bottom: 10px;
}
.buttondemoBasicUsage md-content {
margin-right: 7px;
}
.buttondemoBasicUsage section .md-button {
margin-top: 16px;
margin-bottom: 16px;
}Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
<link rel="stylesheet" type="text/css" href="angular-material.css">
<title>AngularJS</title>
</head>
<body ng-app="MyApp">
<div ng-controller="MyController">
<md-content>
<section layout="row" layout-sm="column" layout-align="center center">
<md-button>{{title1}}</md-button>
</section>
</md-content>
</div>
<script src="app.js"></script>
<script …Run Code Online (Sandbox Code Playgroud)我有一个Hybris系统,在每个数据库表中都有一个名为"hjmpts"的列.该列包含INT值.有人知道这个专栏的原因吗?
我有一个自定义 JsonSerialzier 以特殊格式序列化日期:
public class CustomDateJsonSerializer extends JsonSerializer<Date> {
@Override
public void serialize(Date value, JsonGenerator gen, SerializerProvider arg2) throws IOException, JsonProcessingException {
String outputDateValue;
//... do something with the Date and write the result into outputDateValue
gen.writeString(outputDateValue);
}
}
Run Code Online (Sandbox Code Playgroud)
它工作正常,但如何使用 JUnit 和 Mockito 测试我的代码?或者更确切地说,我如何模拟 JsonGenerator 并访问结果?
感谢您的帮助。
css ×1
html ×1
hybris ×1
java ×1
javascript ×1
junit ×1
mockito ×1
spring ×1
spring-boot ×1
spring-mvc ×1