小编Win*_*ins的帖子

如何在servlet 3.0的web.xml-less中定义<welcome-file-list>和<error-page>?

我有现有的web-app,我想将其转换为web.xml-less servlet 3.0.我已经设法使它工作,但是web.xml中有2个标签,我仍然不知道web.xml-less环境中的等效代码.

<welcome-file-list>
    <welcome-file>/index.jsp</welcome-file>
</welcome-file-list>

<error-page>
    <error-code>404</error-code>
    <location>/pageNotFound</location>
</error-page>
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏

java servlet-3.0 java-ee-6 tomcat7

28
推荐指数
2
解决办法
2万
查看次数

scala 2维数组

这听起来很容易,但我无法做到.

如何在Scala中创建大小为100乘60的二维数组?假设我有一个名为Abcd的类,我想创建一个Abcd的二维数组.我尝试使用以下代码但不起作用.

var myArray = new Array[Array[Abcd]](100,60)
Run Code Online (Sandbox Code Playgroud)

它抱怨"构造函数数组的参数太多"

scala multidimensional-array

17
推荐指数
2
解决办法
2万
查看次数

从多个来源创建分页

我需要创建一个带分页的HTML表.数据来自2个不同的来源(可能是来自2个不同数据库的2个表,如一个Oracle,另一个是MySQL),您无法使用连接的select语句.为了使它更复杂,我需要按升序显示按时间戳排序的数据(其中一个属性是时间戳).

例如,源A有45条记录,源B有55条记录.因此,该表将显示总记录100,但只显示一次说15条记录.所以必须有7页(6页有15条记录,1页有10条记录).

上面的示例总共只有100条记录,内存可能很容易加载它们.但在实际生产中,它可能是数千或数百万条记录.有谁知道我可以使用的任何算法?我可以提供的参数是页码和每页的记录数.

algorithm pagination

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

Java 8默认方法接口覆盖Object equals方法

public interface Table<T> {

    @Overrride
    default boolean equals(Object other) {
        //do something and return true/false
    }
}
Run Code Online (Sandbox Code Playgroud)

为什么上面的代码有编译错误"java:默认方法在接口表中等于覆盖java.lang.Object的成员"?我们不能使用接口默认方法覆盖hashCode和equals方法,大概我在同一个接口中有方法来确定实现这个接口的对象是否相等?

java java-8 default-method

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

什么相当于java config中的<tcp-outbound-channel-adapter>?

我有以下bean的spring集成XML配置

<int-ip:tcp-outbound-channel-adapter id="outboundClient"
channel="input"
connection-factory="client"/>
Run Code Online (Sandbox Code Playgroud)

我认为java配置中的等价物将是

@ServiceActivator(inputChannel = "input", requiresReply = "true")
public TcpSendingMessageHandler outboundClient() {
    TcpSendingMessageHandler tcpSendingMessageHandler = new TcpSendingMessageHandler();
    tcpSendingMessageHandler.setConnectionFactory(clientConnectionFactory());
    tcpSendingMessageHandler.setRetryInterval(10000);
    tcpSendingMessageHandler.setClientMode(true);
    return tcpSendingMessageHandler;
}
Run Code Online (Sandbox Code Playgroud)

但是,在日志中,我看到了

TcpListener exiting - no listener and not single use
Run Code Online (Sandbox Code Playgroud)

我无法收到服务器的回复.

任何帮助表示赞赏

java spring spring-integration spring-java-config

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

ImmutableList不扩展List?

当我深入研究gs-collection源代码时ImmutableList,它不会扩展java.util.List.但是,类javadoc提到All ImmutableList实现必须实现java.util.List.

为什么必须要求实现实现java.util.List而不是ImmutableList自己扩展java.util.List

java collections gs-collections

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

接口中的静态方法需要-target:jvm-1.8

我正在使用gradle 4.5,带有JDK 1.8.0_162的scala 2.11.11 / 2.12.4构建scala项目,在我升级到scala 2.11.12之前,它工作正常。随着2.11.12我不断收到编译错误

Static methods in interface require -target:jvm-1.8
Run Code Online (Sandbox Code Playgroud)

我一直在尝试在Google中搜索并添加诸如

ScalaCompileOptions.metaClass.useAnt = false
Run Code Online (Sandbox Code Playgroud)

要么

targetCompatibility="1.8"
Run Code Online (Sandbox Code Playgroud)

但他们都没有解决这个问题。

scala gradle

5
推荐指数
2
解决办法
1118
查看次数

使用Argonaut创建通用JSON转换器

我是Scala的新手,在这里我正在尝试创建一个基于Argonaut的通用json转换器.我试图搜索谷歌和stackoverflow,但到目前为止,我没有任何线索.

这是我的代码片段.

import org.springframework.http.converter.AbstractHttpMessageConverter
import org.springframework.http.{MediaType, HttpInputMessage, HttpOutputMessage}    
import scala.io.Source
import argonaut._,Argonaut._

case class Currency(code: String)
object Currency {
    implicit def CurrencyCodecJson: CodecJson[Currency] = casecodec1(Currency.apply, Currency.unapply)("code")
}

case class Person(firstName: String, lastName: String)
object Person {
    implicit def PersonCodecJson: CodecJson[Person] = casecodec2(Person.apply, Person.unapply)("firstName", "LastName")
}

class ArgonautConverter extends AbstractHttpMessageConverter[Object](new MediaType("application", "json", Charset.forName("UTF-8")), new MediaType("application", "*+json", Charset.forName("UTF-8"))) {
    val c = classOf[Currency]
    val p = classOf[Person]

    def writeInternal(t: Object, outputStream: OutputStream) = {
        val jsonString = t match {
            case c:Currency …
Run Code Online (Sandbox Code Playgroud)

generics json scala argonaut

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

Jenkins Pipeline 上的动态参数取决于分支

我的詹金斯管道上有类似的东西

properties([
    parameters([
        booleanParam(description: 'Merge master to this branch', name: 'merge_master', defaultValue: false),
        someOtherParameters
    ])
])
Run Code Online (Sandbox Code Playgroud)

显然,如果管道在主分支上运行,则第一个参数没有意义。那么,只有当管道不在 master 分支上运行时,我怎样才能拥有这个参数呢?

jenkins jenkins-pipeline

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

64位机器中的内存分配

我想问一下64位ubuntu Linux中的内存分配问题.

我有以下代码

#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[]) {
    char buffer_one[8], buffer_two[8];

    printf("Size of char: %u\n", sizeof(char));

    printf("Buffer_two is at %p\n", buffer_two);
    printf("Buffer_one is at %p\n", buffer_one);
}
Run Code Online (Sandbox Code Playgroud)

当它运行时,会显示以下结果

$ ./sizeofchar 
Size of char: 1
Buffer_two is at 0x7fff98069910
Buffer_one is at 0x7fff98069900
Run Code Online (Sandbox Code Playgroud)

我的问题是,即使char类型的大小是1字节,我假设(如果我在这里错了请纠正我)Buffer_two并且Buffer_one彼此相邻分配,为什么Buffer_twoBuffer_one内存地址分配16个字节.

c 64-bit gcc callstack

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

无法从守护程序接收消息

我正在尝试设置使用 Jenkins 文件的 Jenkins 多分支管道。我正在配置的项目是使用 gradle 和 jenkins 文件构建的,我有以下代码段

stage('build') sh "./gradlew build --stacktrace"

每次我运行构建时,它总是失败并显示以下错误。我试图禁用 gradle 守护程序,但它一直显示相同的错误。

FAILURE: Build failed with an exception.

* What went wrong:
Could not receive a message from the daemon.

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.launcher.daemon.client.DaemonConnectionException: Could not receive a message from the daemon.
at org.gradle.launcher.daemon.client.DaemonClientConnection.receive(DaemonClientConnection.java:81)
at org.gradle.launcher.daemon.client.DaemonClientConnection.receive(DaemonClientConnection.java:35)
at org.gradle.launcher.daemon.client.DaemonClient.monitorBuild(DaemonClient.java:210)
at org.gradle.launcher.daemon.client.DaemonClient.executeBuild(DaemonClient.java:178)
at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:141)
at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:92)
at …
Run Code Online (Sandbox Code Playgroud)

gradle jenkins jenkins-pipeline

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

为什么调用 lseek 后读取的文件总是返回 0?

我不明白为什么在 lseek 返回读取的 0 个字节后调用 read 。

//A function to find the next note for a given userID;
//returns -1 if at the end of file is reached;
//otherwise, it returns the length of the found note.
int find_user_note(int fd, int user_uid) {
    int note_uid = -1;
    unsigned char byte;
    int length;

    while(note_uid != user_uid) { // Loop until a note for user_uid is found.
        if(read(fd, &note_uid, 4) != 4) // Read the uid data.
            return -1; // If 4 …
Run Code Online (Sandbox Code Playgroud)

c linux ubuntu

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