小编meg*_*off的帖子

Apache Http Client打印"[读取] I/O错误:读取超时""

我正在使用apache http客户端v4.5并将其用作REST客户端.在某些情况下,我识别出一个错误"[读取] I/O错误:读取超时",它来自httpclient框架,当它读取接收到的内容并将其显示为最后一条消息时.

它似乎没有影响,但我想知道是否有人知道它来自何处以及如何解决它.根据以下线程(链接),似乎是"mutlithreaded"配置的问题.

但是我只使用http客户端的默认配置,当我使用版本v4时,我不知道如何将"multithreaded"设置为false以查看它是否有任何区别.

我也试图设置超时但它没有帮助.

任何提示?

日志:

15:48:05.984 [main] DEBUG org.apache.http.wire - http-outgoing-8 << "HTTP/1.1 200 OK[\r][\n]"
15:48:05.984 [main] DEBUG org.apache.http.wire - http-outgoing-8 << "Date: Tue, 29 Dec 2015 14:48:03 GMT[\r][\n]"
15:48:05.984 [main] DEBUG org.apache.http.wire - http-outgoing-8 << "Server: Apache/2.4.12 (Win32) OpenSSL/1.0.1l PHP/5.6.8[\r][\n]"
15:48:05.984 [main] DEBUG org.apache.http.wire - http-outgoing-8 << "X-Powered-By: PHP/5.6.8[\r][\n]"
15:48:05.985 [main] DEBUG org.apache.http.wire - http-outgoing-8 << "Cache-Control: nocache, private[\r][\n]"
15:48:05.985 [main] DEBUG org.apache.http.wire - http-outgoing-8 << "Content-Length: 99[\r][\n]"
15:48:05.985 [main] DEBUG org.apache.http.wire - http-outgoing-8 …
Run Code Online (Sandbox Code Playgroud)

java multithreading timeout httpclient apache-httpcomponents

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

vue + nuxt.js - 如何读取从外部请求接收到的 POST 请求参数

我有一个外部表单,可以向我的 nuxt 应用程序提交发布请求。我目前正在努力找出如何在我的 nuxt 页面中访问这些 POST 请求参数?

到目前为止,我找到了“asyncData”方法,但是当我尝试通过“params”对象访问提交的参数时,它始终是“未定义”。我在这里做错了什么?

我的nuxt页面中的示例代码,假设“email”是从外部提交的请求参数

export default {
 asyncData({ params }) {
    console.log('asyncData called...' + params.email);
    return {email: params.email};
},
Run Code Online (Sandbox Code Playgroud)

外部 html 表单

<body>
    <form action="https://..." target="_blank" method="post">
        <input name="email" class="input" type="text" placeholder="Email" maxlength="255"></input>
        <input name="submit" class="btn" type="submit" value="Ok"></input>
    </form>
</bod>
Run Code Online (Sandbox Code Playgroud)

javascript post node.js vue.js nuxt.js

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

nuxt.js - 如何在服务器端为所有客户端缓存 axios 调用

我正在使用 vue + nuxt.js 应用程序,我想知道是否可以为所有客户端缓存 axios webservice 调用。我必须获得一些货币参考数据,这对于每个客户都必须调用这些数据没有多大意义。

有人可以给我一些提示,甚至是一个例子吗?谢谢。

caching vue.js axios nuxt.js

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

WebFlux 和 Reactor 3.4.0 - 已弃用的 FluxProcessors - 如何使用接收器订阅?

在 Reactor 3.4.0 中,不同的 FluxProcessor(例如“DirectProcessor”)已被弃用。我使用这样的处理器作为订阅者,请参见下面的示例。

现在我想知道如何迁移我的代码才能使用推荐的Sinks.many()方法?有任何想法吗?

旧代码:

DirectProcessor<String> output = DirectProcessor.create();
output.subscribe(msg -> System.out.println(msg));

WebSocketClient client = new ReactorNettyWebSocketClient();
client.execute(uri, session -> 
    // send message
    session.send(Mono.just(session.textMessage(command)))
        .thenMany(session.receive()
        .map(message -> message.getPayloadAsText())
        .subscribeWith(output))
    .then()).block();
Run Code Online (Sandbox Code Playgroud)

根据已弃用的 DirectProcessor 的 JavaDoc,我应该使用Sinks.many().multicast().directBestEffort(). 但我想知道如何在我的 WebSocketClient 中使用它?

迁移代码:

Many<String> sink = Sinks.many().multicast().directBestEffort();        
Flux<String> flux = sink.asFlux();
flux.subscribe(msg -> System.out.println(msg));

WebSocketClient client = new ReactorNettyWebSocketClient();
client.execute(uri, session -> 
    // send message
    session.send(Mono.just(session.textMessage(command)))
        .thenMany(session.receive()
        .map(message -> message.getPayloadAsText())
        .subscribe ...   // <-- how to do …
Run Code Online (Sandbox Code Playgroud)

java spring-websocket spring-webflux

5
推荐指数
0
解决办法
3892
查看次数

oracle sql - 选择带有多个"case when"的语句并检查包含文本

我找了一个工作示例,我可以在案例陈述检查时使用mutliple来验证是否包含特定文本:例如

SELECT 
  ID,
  NAME,
  (SELECT 
      (Case when Contains(Descr,"Test") Then "contains Test" 
        when Contains(Descr, "Other") Then "contains Other"
        Else "No Match" End) From DESCRIPTION
       where item_id = id
  ) as "Match"
  From Item
Run Code Online (Sandbox Code Playgroud)

sql oracle contains case

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

Spring Security中针对@PreAuthorize AccessDeniedException的ErrorHandling返回500,而不是401

亲爱的所有人,我想在Spring 4 Rest应用程序中自定义错误处理,因此,如果我的控制器中@PreAuthorize批注中的检查失败,它应该返回HTTP代码401而不是服务器错误500。

我注册了一个自己的AuthenticationEntryPoint和AuthenticationFailureHandler,其启动/错误处理方法返回401。这对于我的JWT身份验证工作正常,但如果@PreAuthorize检查失败并带有“ AccessDeniedException”,则这些错误方法将永远不会调用,并且spring返回服务器错误500。

我该如何自定义呢?看起来我错过了什么?感谢您提前提供任何提示。

这是我的AuthenticationEntryPoint类:

@Component
public class RestAuthenticationEntryPoint implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException ) throws IOException, ServletException {       
    response.setContentType("application/json");
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    response.getOutputStream().println("{ \"error\": \"" + authException.getMessage() + "\" }");
   }
}
Run Code Online (Sandbox Code Playgroud)

这是我的AuthenticationFailureHandler:

public class JWTAuthenticationFailureHandler implements AuthenticationFailureHandler {
    @Override
    public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
    response.sendError(401, (new StringBuilder()).append("Authentication Failed: ").append(exception.getMessage()).toString());
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的春季安全配置

<security:global-method-security pre-post-annotations="enabled"/>

<security:http  pattern="/api/**" entry-point-ref="restAuthenticationEntryPoint"  >
    <security:csrf disabled="true"/>
    <security:intercept-url pattern="/api/**" access="isAuthenticated()" /> …
Run Code Online (Sandbox Code Playgroud)

java rest spring spring-mvc spring-security

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

如何通过属性配置 java.util.logging 以使用标准输出?

如何通过属性配置 java.util.logging 以使用标准输出而不是标准错误?

我当前的财产文件

# Logging
handlers = java.util.logging.ConsoleHandler
# Console Logging
java.util.logging.ConsoleHandler.level = ALL
java.util.logging.ConsoleHandler.formatter =  java.util.logging.SimpleFormatter 
java.util.logging.SimpleFormatter.format = %1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %4$s %2$s %5$s%6$s%n
Run Code Online (Sandbox Code Playgroud)

java logging properties

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

xpath 表达式 - 选择父元素包含特定文本的元素

我目前很难找到正确的 xpath 表达式来选择一个输入元素,其中其父/兄弟元素包含特定文本。

在下面的示例中,我想选择“输入”元素,其中在同一tr行中td存在具有特定文本的元素。

我的示例路径- 不返回匹配项

//input[contains(../../../td/text(),"15-935-331")]
Run Code Online (Sandbox Code Playgroud)

源代码

<tr>
    <td><a href="xxx" target="_blank">xxxx, yyyyy</a></td>
    <td>Mr</td>
    <td></td>
    <td> 15-935-331</td>
    <form id="betreuerModel" action="xxxx" method="POST">
      <td class="tRight">
        <input value="Bearbeiten" id="bearbeiten" name="bearbeiten" class="submit" title="Bearbeiten" type="submit"/>
      </td>
    </form>
</tr>
<tr>
 // .. next row with same structure
</tr>
Run Code Online (Sandbox Code Playgroud)

html firefox xpath

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

Vaadin flow - 在不同的包中拥有视图

vaadin flow 中是否存在一个选项,可以将视图放在不同的包中,而不是作为主 Spring Boot 类所在的子包?例如

com.xyz.vaadin.app --> Spring Boot Main
com.xyz.vaadin.config
com.xyz.vaadin.views  --> Main view
Run Code Online (Sandbox Code Playgroud)

我已经尝试使用“@SpringBootApplication scanBasePackages”或“scanBasePackageClasses”并传递了主视图包或主视图类,但在启动应用程序后,它没有找到视图。错误“找不到路线”

java vaadin vaadin-flow

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

Vaadin Flow - 如何添加自定义图标集?

我正在使用 vaadin flow v21。我喜欢创建一个使用自己的 svg 图标集的自定义组件。我尝试根据 vaadin-icon 创建集合,但 svg 定义不会复制到影子根中。

我做了以下事情

  1. 创建了一个CustomIcon派生自的 Component 类com.vaadin.flow.component.icon.Icon
  2. 添加了一个JSModule,其中将包含新图标集作为聚合物模板。

自定义组件类

@JsModule("./icons/custom-iconset-svg.js")
public class CustomIcon extends Icon {

    public CustomIcon(String collection, String icon) {
      super(collection,icon);
    }
}
Run Code Online (Sandbox Code Playgroud)

文件“自定义图标集-svg.js”

import '@vaadin/vaadin-icon/vaadin-iconset.js';
import '@vaadin/vaadin-icon/vaadin-icon.js';

const $_documentContainer = document.createElement('template');

$_documentContainer.innerHTML = `<vaadin-iconset-svg name="custom" size="16">
<svg>
<defs>
<vaadin-iconset name="vaadin" size="16">
<svg><defs>
<g id="custom:abacus"><path d="..."></path></g>
</defs>
</svg>
</vaadin-iconset-svg>`;

document.head.appendChild($_documentContainer.content);
Run Code Online (Sandbox Code Playgroud)

新“CustomIcon”类的使用

Icon icon = new CustomIcon("custom","abacus")
add(icon);
Run Code Online (Sandbox Code Playgroud)

这会稍后创建以下 html 元素

  1. 它在该<head>部分中添加了自定义图标集<vaadin-iconset-svg name="custom" ... …

javascript java svg polymer vaadin-flow

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