小编idi*_*ous的帖子

Jquery Ajax请求不在IE 10上工作(由于缓存)

我想从这开始.我厌倦了IE.我有以下代码:

$(function () {
$("#cal").on('click', "#forward", function () {
    $.ajax({
        url: "Home/Calendar?target=forward",
        type: "GET",
        success: function (result) {
            $("#cal").html(result);
        }
    });
  });
});

 $(function () {
$("#cal").on('click', "#backwards", function () {

    $.ajax({
        url: "Home/Calendar?target=backwards",
        type: "GET",
        success: function (result) {
            $("#cal").html(result);
        }
    });
});
});
Run Code Online (Sandbox Code Playgroud)

它是对C#MVC应用程序中的控制器操作的ajax调用.它只是在日历的几个月里来回取代html.现在我知道你需要重新挂起事件html(),这就是我使用on()JQuery 1.7的原因.我也用过delegate().在FF中,Chrome可以按预期工作.在IE 10中它没有.我很茫然.我知道IE在IE8中与委托有问题,而JQuery <1.5但是事实并非如此.

有谁知道如何解决这个问题?

c# jquery internet-explorer asp.net-mvc-4

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

随机化真正巨大的文本文件的行

我想将文件中的行随机化,该文件包含超过3200万行10位数字符串.我知道如何使用它,File.ReadAllLines(...).OrderBy(s => random.Next()).ToArray()但这不是内存效率,因为它将所有内容加载到内存(超过1.4GB),只适用于x64架构.

另一种方法是拆分它并随机化较短的文件然后合并它们但我想知道是否有更好的方法来做到这一点.

c# memory performance file-io

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

字符串至少包含一个数字

我试图查看字符串是否至少包含一个数字或小写或大写.

我写过这样的话:

      int combinations = 0;
      string pass = "!!!AAabas1";

      if (pass.matches("[0-9]")) {
          combinations = combinations + 10;
      }

      if (pass.matches("[a-z]")) {
          combinations =combinations + 26;
      }

      if (pass.matches("[A-Z]")) {
          combinations =combinations + 26;
      }
Run Code Online (Sandbox Code Playgroud)

但是我不明白为什么我不能得到组合去36.他们只是保持在0.我做错了什么?

java regex

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

Jaxb2使用每个mvn clean软件包重新生成类

我的pom看起来像

<plugins>
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.12.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemaLanguage>WSDL</schemaLanguage>
                <generateDirectory>src/main/java</generateDirectory>
                <schemaDirectory>src/main/resources/wsdl/</schemaDirectory>
                <schemaIncludes>
                    <include>*.xsd</include>
                    <include>draw/*.xsd</include>
                </schemaIncludes>
            </configuration>
        </plugin>

    </plugins>
Run Code Online (Sandbox Code Playgroud)

当我这样做时,mvn clean package它是根据配置构建的。但是,一旦构建了它,我就不想每次都构建它,mvn clean package除非XSD已对其进行了某种修改。

我该如何实现?

jaxb jaxb2 maven maven-jaxb2-plugin

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

HttpClient 连接池关闭

我正在使用 HttpClient v4.5.5

我有一个HttpClient如下:

PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager();
    connManager.setMaxTotal(totalMaxConnections);
    connManager.setDefaultMaxPerRoute(defaultMaxConnPerRoute);
CloseableHttpClient httpClient =HttpClients.custom().setConnectionManager(connManager).setConnectionManagerShared(true).build();
Run Code Online (Sandbox Code Playgroud)

然后我使用 http 客户端如下:

protected Response connect(final Function<AbstractHttpAdapter, CloseableHttpResponse> pcAction) {
    Response response = null;
    final Instant begin = Instant.now();
    try {
        final CloseableHttpResponse closableResp = pcAction.apply(this);
        try {
            final Instant end = Instant.now();
            if (closableResp != null) {
                final HttpEntity responseEntity = closableResp.getEntity();
                if (responseEntity != null) {
                    response = new Response();
                    InputStream is = responseEntity.getContent();
                    try {

                        final ContentType contentType = ContentType.getOrDefault(responseEntity);
                        Charset …
Run Code Online (Sandbox Code Playgroud)

java apache-httpcomponents apache-httpclient-4.x

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

选择更新行为

我很好地理解当使用 SELECT FOR UPDATE 并发生另一个 SELECT/UPDATE 时,行的更新会发生什么。但是,当使用 SELECT FOR UPDATE 发出两个请求时会发生什么。

例如:

  1. 线程 A启动一个事务,对一行执行 SELECT FOR UPDATE,检索一些信息并开始一个需要时间的 HTTP 请求。调用返回后,事务被提交并且会话被关闭
  2. 当 A 等待请求时,线程 B启动一个新事务并在同一行上执行 SELECT FOR UPDATE。它将检索信息并继续处理 HTTP 请求,还是等待线程 A 提交/执行更新,然后从行中检索数据。

我不关心一旦请求返回并且更新表的时间到来时会发生什么。用于更新的第二个将抛出或更新该行上的最后一个可能的数据。

但是实际的HTTP请求会由他们两个来完成吗?换句话说,在这种情况下 SELECT FOR UPDATE 是否可以被使用(滥用)作为线程同步机制?

postgresql concurrency multithreading thread-safety select-for-update

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

针对不同消费者的每条消息的 Spring Cloud Stream 主题

我正在寻找的拓扑是

在此输入图像描述

到目前为止,我还没有看到在 Cloud Stream 中定义每条消息的主题的方法。我知道消费者将绑定到特定主题,但是生产者在将消息发送到交换器之前如何设置每条消息的主题?

source.output().send(MessageBuilder.withPayload(myMessage).build());
Run Code Online (Sandbox Code Playgroud)

不提供任何方法来设置交换的主题以路由到正确的消费者。

或者也许我不理解正确的东西?

更新

我希望不会在消费者中收到消息,因为bindingRoutingKey2222正在发送routeTo 1111. 但我仍然在消费者身上收到它。

生产者属性:

spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest

spring.cloud.stream.bindings.output.content-type=application/json
spring.cloud.stream.bindings.output.destination=messageExchange
spring.cloud.stream.rabbit.bindings.output.producer.routing-key-expression=headers['routeTo']


@EnableBinding(Source.class)
@SpringBootApplication
public class Application {

   public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
  }

}
Run Code Online (Sandbox Code Playgroud)

发件人:

source.output().send(MessageBuilder.withPayload(mo).setHeader("routeTo", "1111").build());

以及消费者:

spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest

spring.cloud.stream.bindings.input.destination=messageExchange
spring.cloud.stream.rabbit.bindings.input.consumer.bindingRoutingKey=2222
Run Code Online (Sandbox Code Playgroud)

应用:

@SpringBootApplication
@EnableBinding(Sink.class)
public class Application {

private static final Logger log = LoggerFactory.getLogger(Application.class);

public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
}

@StreamListener(Sink.INPUT)
public void ReceiveMo(String moDTO) …
Run Code Online (Sandbox Code Playgroud)

spring spring-cloud spring-cloud-stream

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

动态更改在 tomcat 上运行的 Web 应用程序的 Logback 级别

我在 Tomcat 7 上运行的 java Web 应用程序的资源文件夹中有一个。logback.xml有没有办法在应用程序运行时动态更改应用程序某些类的调试级别?

标准做法是从 CLI 运行一个普通的 java jar,只需logback.xml使用 vim 进行编辑,一段时间后日志就会更新。这对于 tomcat 是否可行,因为我尝试过,但 id 似乎不起作用。

还有更好的办法吗?

java tomcat logback slf4j

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

来自unix时间戳的DateTime错误

我有一个字符串"2013-10-09 00:00:00",我使用下面的代码将其更改为时间戳

date_default_timezone_set($timeZone);
$timeStamp = strtotime("2013-10-09 00:00:00"); //echos 1381269600
Run Code Online (Sandbox Code Playgroud)

当我做

date_default_timezone_set($timeZone);
date("Y-m-d H:m",$timeStamp);
Run Code Online (Sandbox Code Playgroud)

我得到2013年10月9日00:10:00.这完全是奇怪的.为什么我会得到这10分钟的差异?

php timezone datetime

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