小编Xar*_*lus的帖子

React SSR、NextJS 与 Chrome 无头预渲染

对于服务器端渲染,我发现了两种方法:

NextJs 在 GitHub 上有很多明星和一个很棒的社区,但另一种方法(chrome 无头预渲染)似乎更干净,需要几乎零配置才能工作。

有没有人有与他们一起工作的经验?
每种方法的主要优缺点是什么?

javascript reactjs server-side-rendering next.js

8
推荐指数
1
解决办法
1839
查看次数

如何在 create-react-app 项目中重命名 index.html?

我正在使用 Surge 来托管我的 create-react-app 网站,为了使用客户端路由,您需要使用入口点,200.html但是在使用 create-react-app 时,它默认设置为index.html. 在不破坏网站的情况下重命名该文件的最佳方法是什么?

javascript reactjs react-router surge.sh

6
推荐指数
2
解决办法
9304
查看次数

create-react-app在生产中显示我的所有代码,如何将其隐藏?

shown_all_files

在我的chrome来源标签中,我可以按确切的文件夹位置查看我的所有文件。我怎么藏起来?

这些不是我以前的项目中的问题,它是在不使用create-react-app的情况下完成的。

javascript reactjs create-react-app

6
推荐指数
4
解决办法
2389
查看次数

Redirection inside reactive Spring Webflux REST controller

I'm creating simple controller server for spring reactive project. While setting redirection to another location, I have found an error when calling http://localhost:8080/:

There was an unexpected error (type=Internal Server Error, status=500).
ModelAttributeMethodArgumentResolver does not support multi-value reactive type wrapper: interface reactor.netty.http.server.HttpServerResponse
java.lang.IllegalStateException: ModelAttributeMethodArgumentResolver does not support multi-value reactive type wrapper: interface reactor.netty.http.server.HttpServerResponse
    at org.springframework.util.Assert.state(Assert.java:94)
    at org.springframework.web.reactive.result.method.annotation.ModelAttributeMethodArgumentResolver.resolveArgument(ModelAttributeMethodArgumentResolver.java:112)
    at org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:123)
    at org.springframework.web.reactive.result.method.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:190)
    at org.springframework.web.reactive.result.method.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:133)
    at org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter.lambda$handle$1(RequestMappingHandlerAdapter.java:200)
    at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:44)
...
Run Code Online (Sandbox Code Playgroud)

This is the controller code:

There was an unexpected error (type=Internal …
Run Code Online (Sandbox Code Playgroud)

java reactive-programming spring-restcontroller spring-webflux

6
推荐指数
2
解决办法
3648
查看次数

在 Spring Webflux 中添加的多个 cookie 未合并到单个 HTTP 标头中

我正在尝试使用包含多个 cookie 的 Spring Webflux 的 WebClient 发送请求。我的代码如下所示:

Mono<Void> loginCall = webClient.post()
                           .uri("/Sites/Login")
                           .cookie("key1", "value1")
                           .cookie("key2", "value2")
                           .cookie("key3", "value3")
                           .exchange()
                           .flatMap(clientResponse -> clientResponse.bodyToMono(Void.class));
Run Code Online (Sandbox Code Playgroud)

我在端点上收到的内容如下所示(注意多个 cookie 标头):

$ nc -l -p 8989
POST /Sites/Login HTTP/1.1
user-agent: ReactorNetty/0.8.11.RELEASE
host: localhost:8989
accept: */*
transfer-encoding: chunked
cookie: key1=value1
cookie: key2=value2
cookie: key3=value3
Run Code Online (Sandbox Code Playgroud)

我的期望是收到这样的 HTTP 请求(单个 cookie 标头):

cookie: key1=value1; key2=value2; key3=value3
Run Code Online (Sandbox Code Playgroud)

我正在使用 Spring Boot 2.1.8。

我尝试了很多方法,但我尝试的所有方法都会导致多个 cookie 标头。HTTP 规范非常清楚不能使用多个 cookie 标头(并且我的 Web 服务器接收此请求也不喜欢它)。

如何向 WebClient 请求添加多个 cookie,以便将它们合并到单个 HTTP 标头中?(是的,我可以开始手动设置标题并合并 cookie,但这不知何故感觉不对)

java cookies spring spring-webflux

6
推荐指数
1
解决办法
692
查看次数

PHP - 如何在执行脚本时获得部分输出?

描述:

我有一个脚本,可以在更长的时间内执行多个操作.在标准情况下,PHP脚本的输出在完全执行此脚本后发送.如果我的脚本加载很长时间没有任何响应,用户可能会失望.

要解决的问题:

假设我在这个脚本中有一个循环,它将工作10次.每次执行后我都希望输出到浏览器"Element X finished. Y time.".X和Y的值将发生变化.

题:

有没有办法达到这个效果?也许从这个脚本到新脚本的某种调用,它将通过AJAX将数据发送到浏览器.

或者有没有办法只用PHP实现达到这个效果?

编辑:

我知道我必须澄清这个问题.我希望此信息在页面上动态显示.我已经尝试了输出缓冲区功能,但它仍然无法正常工作.完全执行脚本后,将显示浏览器中的输出.测试代码:

for ($i = 0; $i <= 10; $i++) {
    ob_start();

    echo "Output " . $i . "<br />";

    ob_flush(); //also only flush() etc.


    sleep(1);
}
Run Code Online (Sandbox Code Playgroud)

javascript php

5
推荐指数
1
解决办法
3799
查看次数

用于类型转换/类型绑定/类型推断等的编译时或运行时

我对 Java 比较陌生,去年的一次考试让我陷入了困境。

该任务要求我区分哪些选项在编译时/运行时运行。

  1. 类型铸造。
  2. 后期绑定。
  3. 可访问性检查。
  4. 类型推断。
  5. 键入擦除。
  6. 类型检查。

我可以阅读任何资源来提高我对静态/动态绑定的理解吗?

java

1
推荐指数
1
解决办法
2866
查看次数