这是我的用户视图控制器页面:
@RequestMapping(value="/list")
public ModelAndView listOfUsers() {
ModelAndView modelAndView = new ModelAndView("list-of-users");
List<User> users = userService.getUsers();
PagedListHolder<User> pagedListHolder = new PagedListHolder<>(users);
//pagedListHolder.setPageSize(1);
modelAndView.addObject("users", pagedListHolder);
return modelAndView;
}
Run Code Online (Sandbox Code Playgroud)
这是我的JSP页面:
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>List of users</title>
</head>
<body>
<h1>List of users</h1>
<p>Here you can see the list of the users, edit them, remove or update.</p>
<table …Run Code Online (Sandbox Code Playgroud) 您好我遇到了问题.当我尝试导航到不被允许的页面时,我的CanActivate警卫会被调用两次,因为我没有登录.
我有1个根模块,并提供了我的CanActivate后卫和其他服务.
先感谢您!
这是我的路由器:
const appRoutes: Routes = [
{
path: "",
pathMatch: "full",
redirectTo: "/meal-list",
},
{
path: "login",
component: LoginComponent,
},
{
path: "meal-list",
component: MealListComponent,
canActivate: [AuthActivateGuard],
}
];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes, {useHash: true});
Run Code Online (Sandbox Code Playgroud)
守卫:
@Injectable()
export class AuthActivateGuard implements CanActivate {
constructor(private authService: AuthService,
private router: Router) {
console.log("guard created");
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean>|boolean {
if (!this.authService.authenticated) {
return this.authService.checkLogged().map(res => {
this.authService.authenticated = true;
return true;
}).catch(()=> {
this.authService.authenticated = …Run Code Online (Sandbox Code Playgroud) 我有一个非常简单的应用程序,我读到我可以使用 NettyServerCustomizer 来自定义 NettyServer。但它不起作用,没有调用 NettyServerCustomizer 接口的实现。项目由 Spring Initializr 生成
申请代码:
@SpringBootApplication
@RestController
@RequestMapping("/test")
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@GetMapping
public Mono<String> test() {
return Mono.just("test");
}
@Bean
public NettyServerCustomizer nettyCustomizer() {
return builder -> builder.port(9909);
}
}
Run Code Online (Sandbox Code Playgroud)
绒球
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build> …Run Code Online (Sandbox Code Playgroud) 我有一个里面有很长字符串的 flex 项目,我希望它被包裹起来。但它不起作用。
flex 1 1 500px例如,我设置了 ( flex-basis = 500px) 并且它应该用word wrap: break-word
但它没有,只有当我设置时width=500px,它才开始工作,所以问题是为什么flex-basis 500px不工作而宽度工作?
HTML:
<div class="map-detail-wrapper">
<div class="ad-detail-text">
<span>{{ad.text}}</span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.map-detail-wrapper {
display: flex;
flex-wrap: wrap;
}
.ad-detail-text {
flex: 1 1 0%;
width: 500px;
line-height: 20px;
font-size: 14px;
margin: 20px;
border: black;
word-wrap: break-word;
overflow: hidden;
}
Run Code Online (Sandbox Code Playgroud) 我正在构建媒体播放器,并希望处理来自“播放”、“暂停”等通知的操作。在我的活动中,我注册了MediaButtonReceiver
registerReceiver(MediaButtonReceiver(), IntentFilter(Intent.ACTION_MEDIA_BUTTON))
Run Code Online (Sandbox Code Playgroud)
并创建了媒体通知
val builder: NotificationCompat.Builder = MediaStyleHelper.from(this, mediaSession!!)
builder.addAction(
NotificationCompat.Action(
android.R.drawable.ic_media_previous,
"Previous",
MediaButtonReceiver.buildMediaButtonPendingIntent(this, PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS)
)
)
Run Code Online (Sandbox Code Playgroud)
但是当我按下媒体通知上的操作按钮时,没有任何反应。当我添加这些动作时,执行
MediaButtonReceiver.buildMediaButtonPendingIntent(this, PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS)
Run Code Online (Sandbox Code Playgroud)
打印到控制台警告
“W/MediaButtonReceiver:在给定的上下文中找不到唯一的媒体按钮接收器,因此无法构建待处理的意图。”
但是,如果我以编程方式注册了它,为什么它没有注册?
spring-mvc ×2
android ×1
angular ×1
css ×1
flexbox ×1
jsp ×1
pagination ×1
spring ×1
spring-boot ×1
spring-web ×1