我想知道如果像Tomcat,Jetty等servlet容器已经使用nio来读取和写入数据,是否真的需要使用setWritelistner和setReadListnerservlet输入和输出流?是否有额外的性能提升?
与此类似,我如何在Perl中实现相同的目标?
我想转换
C:\Dir1\SubDir1\` to `C:/Dir1/SubDir1/
Run Code Online (Sandbox Code Playgroud)
我试图按照这里给出的例子,但是当我说出类似的话
my $replacedString= ~s/$dir/"/"; # $dir is C:\Dir1\SubDir1\
Run Code Online (Sandbox Code Playgroud)
我收到编译错误.我已经尝试转义正斜杠,但我得到其他编译器错误.
我正在尝试从Java堆栈中删除换行符.
我遵循了logback模式 -
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %replace(%msg){'\n', ''}%n</pattern>
Run Code Online (Sandbox Code Playgroud)
我希望它能替换消息中的换行符,但它没有这样做.我看到用新行打印出的stacktraces.
但是,如果我使用以下模式(仅用于测试目的) -
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %replace(%msg){'.*', 'x'}%n</pattern>
Run Code Online (Sandbox Code Playgroud)
我发现消息正在被字符x替换,但堆栈跟踪仍然按原样打印.
这让我相信logback会独立地处理堆栈跟踪.我已经通过了logback文档,它说可以通过(%ex)引用stacktraes.
但是,我一次只能为一个appender激活一个模式.我如何确保我没有在stacktraces中获取换行符?
我试图在这里遵循这个例子 - https://gist.github.com/morhekil/1ff0e902ed4de2adcb7a#file-nginx-conf但是得到错误 - "set" directive is not allowed here
我究竟做错了什么?请注意,我使用openresty并调用nginx作为 -
nginx -p `pwd`/ -c conf/nginx.conf
Run Code Online (Sandbox Code Playgroud)
我的nginx.conf的上下文完全匹配https://gist.github.com/morhekil/1ff0e902ed4de2adcb7a#file-nginx-conf
如果我将set变量移动到服务器部分,我不再得到该错误但是新的错误 -
nginx: [emerg] unknown "resp_body" variable
Run Code Online (Sandbox Code Playgroud) 我已经查看了SO中列出的所有解决方案,但似乎无法使其正常工作.我有一个简单的spring-security xml文件 -
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd">
<http auto-config='true' use-expressions="true">
<intercept-url pattern="/**" access="hasRole('ROLE_USER')"/>
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="user" password="user" authorities="ROLE_USER"/>
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>
Run Code Online (Sandbox Code Playgroud)
我的注销页面看起来像这样 -
<form action="j_spring_security_logout" method="post" id="logoutForm">
<input type="hidden"
name="${_csrf.parameterName}"
value="${_csrf.token}" />
</form>
<script>
function formSubmit() {
document.getElementById("logoutForm").submit();
}
</script>
<c:if test="${pageContext.request.userPrincipal.name != null}">
<h2>
Welcome : ${pageContext.request.userPrincipal.name} |
<a href="javascript:formSubmit()"> Logout</a>
</h2>
</c:if>
Run Code Online (Sandbox Code Playgroud)
但是当我进行HTTP POST时,我收到404错误; Spring提供以下错误消息 -
WARNING: No mapping found for HTTP request with URI [/j_spring_security_logout] in …Run Code Online (Sandbox Code Playgroud) 我有一个简单的SQL表,看起来像这样-
CREATE TABLE msg (
from_person character varying(10),
from_location character varying(10),
to_person character varying(10),
to_location character varying(10),
msglength integer,
ts timestamp without time zone
);
Run Code Online (Sandbox Code Playgroud)
我想为表中的每一行找出过去3分钟内是否有不同的“ from_person”和“ from_location”与当前行中的“ to_person”进行了交互。
例如,在上表中,对于第4行,除了孟买的mary(当前行)之外,纽约市的nancy和巴塞罗那的bob也在最近3分钟内向charlie发送了一条消息,因此计数为2。
同样,对于第2行,除了巴塞罗那(当前行)的bob以外,只有纽约市的nancy向ca(当前行)的查理发送了一条消息,因此计数为1
示例所需的输出-
0
1
0
2
Run Code Online (Sandbox Code Playgroud)
我尝试使用窗口函数,但似乎在frame子句中我可以指定前后的行数,但不能指定时间本身。
我们使用一个自定义_id字段,它是一个long值。我想获得最大 _id 值。我正在进行的搜索是 -
{
"stored_fields": [
"_id"
],
"query": {
"match_all": {}
},
"sort": {
"_id": "desc"
},
"size": 1
}
Run Code Online (Sandbox Code Playgroud)
但我从 ES 5.1 收到错误消息:
"reason": {
"type": "illegal_argument_exception",
"reason": "Fielddata access on the _uid field is disallowed"
}
Run Code Online (Sandbox Code Playgroud)
那么,我该如何获取 的最大值呢_id?我真的不想_id在文档中存储副本只是为了获得最大值。
我有一个带有static两个参数的方法的类 - HttpServletRequest request和HttpServletResponse response:
public class RequestProcessor {
public static processRequest(HttpServletRequest request, HttpServletResponse response) {
//read request and write data to response
}
}
Run Code Online (Sandbox Code Playgroud)
几个线程可以同时调用RequestProcessor.processRequest方法.
经过一些研究后,我的理解是,因为堆栈是线程的本地所以它不应该是一个问题,但我不确定这个代码是否仍然是线程安全的,因为HttpServletRequest请求和HttpServletResponse响应不是不可变的
假设我的JSON看起来像这样(这里提供示例) -
{
"year" : 2013,
"title" : "Turn It Down, Or Else!",
"info" : {
"directors" : [
"Alice Smith",
"Bob Jones"
],
"release_date" : "2013-01-18T00:00:00Z",
"rating" : 6.2,
"genres" : [
"Comedy",
"Drama"
],
"image_url" : "http://ia.media-imdb.com/images/N/O9ERWAU7FS797AJ7LU8HN09AMUP908RLlo5JF90EWR7LJKQ7@@._V1_SX400_.jpg",
"plot" : "A rock band plays their music at high volumes, annoying the neighbors.",
"rank" : 11,
"running_time_secs" : 5215,
"actors" : [
"David Matthewman",
"Ann Thomas",
"Jonathan G. Neff"
]
}
}
Run Code Online (Sandbox Code Playgroud)
我想查询所有genres包含的电影Drama.
我浏览了所有示例,但似乎我只能查询散列键和排序键.我不能将JSON文档作为密钥本身,因为不支持.
我有以下代码来回显 Netty 收到的输入-
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
public class MyHandler extends SimpleChannelInboundHandler{
@Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
ByteBuf in = (ByteBuf) msg;
try {
System.out.println(in.toString(io.netty.util.CharsetUtil.US_ASCII));
} finally {
in.release();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我调用它如下-
try {
ServerBootstrap b = new ServerBootstrap(); // (2)
b.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class) // (3)
.childHandler(new ChannelInitializer<SocketChannel>() { // (4)
@Override
public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(new MyHandler());
}
})
.option(ChannelOption.SO_BACKLOG, 128) // (5)
.childOption(ChannelOption.SO_KEEPALIVE, true); // (6)
// …Run Code Online (Sandbox Code Playgroud)