小编qas*_*zee的帖子

你如何在Javascript中舍入到小数点后1位?

你可以将javascript中的数字舍入到小数点后的1个字符(正确舍入)吗?

我尝试了*10,round,/ 10但它在int的末尾留下了两位小数.

javascript rounding

344
推荐指数
11
解决办法
32万
查看次数

我刚刚发现为什么所有的ASP.Net网站都很慢,而我正试图找出解决方法

我刚刚发现,ASP.Net Web应用程序中的每个请求在请求开始时都会获得一个Session锁,然后在请求结束时释放它!

如果这对你造成影响,就像我一开始对你而言,这基本上意味着以下几点:

  • 任何时候ASP.Net网页需要很长时间才能加载(可能是由于数据库调用速度慢等),并且用户决定他们想要导航到另一个页面,因为他们厌倦了等待,他们不能!ASP.Net会话锁强制新页面请求等待,直到原始请求完成其缓慢的负载.Arrrgh.

  • 任何时候UpdatePanel加载缓慢,并且用户决定在UpdatePanel完成更新之前导航到另一个页面......他们不能!ASP.net会话锁强制新页面请求等待原始请求完成其缓慢的负载.双Arrrgh!

那有什么选择呢?到目前为止,我想出了:

  • 实现ASP.Net支持的自定义SessionStateDataStore.我没有找到太多的副本,它似乎有点高风险,容易搞砸.
  • 跟踪正在进行的所有请求,如果来自同一用户的请求,则取消原始请求.看起来有点极端,但它会起作用(我认为).
  • 不要使用Session!当我需要用户的某种状态时,我可以使用Cache代替,以及经过身份验证的用户名上的关键项,或者其他类似的东西.再次看起来有点极端.

我真的不敢相信ASP.Net微软团队会在版本4.0的框架中留下如此巨大的性能瓶颈!我错过了一些明显的东西吗 为会话使用ThreadSafe集合有多难?

architecture asp.net iis performance session

272
推荐指数
8
解决办法
11万
查看次数

java.io.IOException:不支持mark/reset

try {
    //String location = dir1.getCanonicalPath()+"\\app_yamb_test1\\mySound.au";
    //displayMessage(location);
    AudioInputStream audio2 = AudioSystem.getAudioInputStream(getClass().getResourceAsStream("mySound.au"));
    Clip clip2 = AudioSystem.getClip();
    clip2.open(audio2);
    clip2.start();
} catch (UnsupportedAudioFileException uae) {
    System.out.println(uae);
    JOptionPane.showMessageDialog(null, uae.toString());
} catch (IOException ioe) {
    System.out.println("Couldn't find it");
    JOptionPane.showMessageDialog(null, ioe.toString());
} catch (LineUnavailableException lua) {
    System.out.println(lua);
    JOptionPane.showMessageDialog(null, lua.toString());
}
Run Code Online (Sandbox Code Playgroud)

当我从netbeans运行应用程序时,此代码工作正常.声音播放,没有例外.但是,当我从dist文件夹运行它时,声音不会播放,我java.io.IOException: mark/reset not supported在消息对话框中显示.

我怎样才能解决这个问题?

java audio ioexception

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

如何将包含多个参数的URL传递到URL?

基本上我正在尝试传递这样的URL:

www.foobar.com/?first=1&second=12&third=5
Run Code Online (Sandbox Code Playgroud)

进入这样的URL:

http://www.facebook.com/sharer.php?&t=FOOBAR&u=http://www.foobar.com/first=12&sec=25&position=2
Run Code Online (Sandbox Code Playgroud)

它只识别第一个参数.我在LinkedIn和Twitter分享方面遇到同样的问题,所以一定是我做错了.

html javascript query-parameters

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

你如何从PHP中的URL中删除域名?

我正在寻找一种方法(或函数)去掉任何提供给函数的URL的domain.ext部分.域扩展可以是任何东西(.com,.co.uk,.nl,.whatever),并且输入它的URL可以是从http://www.domain.com到www.domain.com/path的任何内容./script.php?=whatever

这是最好的方法吗?

php urlparse

46
推荐指数
4
解决办法
5万
查看次数

使用Spring MVC在应用程序启动时执行Java类

使用Spring MVC在应用程序启动时执行Java类的最佳方法是什么?

java spring spring-mvc

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

PHP的类似jQuery的界面?

我很好奇是否存在用于处理HTML/XML文件的PHP的jQuery样式接口/库 - 特别是使用jQuery样式选择器.

我想做这样的事情(所有假设):

foreach (j("div > p > a") as anchor) {
   // ...
}


print j("#some_id")->html();


print j("a")->eq(0)->attr("name");

这只是几个例子.

我尽可能多地使用谷歌搜索,但找不到我想要的东西.有没有人知道这些东西是否存在,或者这是我将要使用domxml从头开始制作的东西?

html php xml jquery html-parsing

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

字符串日期当前日期/时间?

我在用 $date = date("D M d, Y G:i");.

当我回音时$date,它显示正确的日期/时间.现在我需要这个字符串.

我试过了string($date); 但这里什么都没发生 和

$today = strtotime($date); 
Run Code Online (Sandbox Code Playgroud)

在这里我得到奇怪的数字..

我需要一个字符串,所以我可以$today输入一条消息.

这是正确的方法是什么?

php datetime

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

使用sails.js实现passport-http-bearer标记

我正在尝试实施护照的passport-http-bearer策略,但它没有找到有信息的用户Bearer realm="Users".

request是一个帖子请求:

{'token':'simple_access_token',} 
Run Code Online (Sandbox Code Playgroud)

任何人都知道为什么会出现这种错误?我也知道这req应该是httpsssl代替http.我怎么做?

我使用的代码是:

bearerPassportToken: function(req,res){
        passport.authenticate('bearer', function(err, user, info){
          if ((err) || (!user)) {
            if (err) return;
            if (!user)  
                console.log("info);//Info: Bearer realm="Users"
            res.redirect('/login');
            return;
          }
          req.logIn(user, function(err){
            if (err){
                res.redirect('/login');
            }
            //Need to write code for redirection
            ;
          });
        })(req, res);
    },
Run Code Online (Sandbox Code Playgroud)

node.js express http-token-authentication sails.js passport.js

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

PHP通过sftp从远程服务器下载

这可能是之前被问到的,我是PHP的新手,我正尽力学习,但这真的让我感到震惊.

基本上我想知道的是,我如何使用PHP代码将其从远程服务器下载到本地位置.它正在下载所有不仅仅是我坚持的文件.那么请有人向我展示/解释我将如何做到这一点?

提前致谢.

到目前为止我得到了什么

<?php
$connection - ssh2_connect('example.com', 22);
ssh2_auth_password($connection, 'username', 'password');

$remote_dir="/remote_dir/";
$local_dir="/local_dir/";

$remote ="$remote_dir";
$stream = ssh2_exec($connection, $remote);
stream_set_blocking($stream,true);
$command=fread($stream,4096);

$array=explode(\n,$command);

$total_files=sizeof($array);

for($i=0;$i<$total_files;$i+++){
    $file_name=trim($array[$i]);
    if($file_name!=''{
        $remote_file=$remote_dir.$file_name;
        $local_file=$local_dir.$file_name;

        if(ssh2_scp_recv($connection, $remote_file,$local_file)){
            echo "File ".$file_name." was copied to $local_dir<br />"; 
        }
    }
}
fclose($stream);
?>
Run Code Online (Sandbox Code Playgroud)

我想我的$ remote ="$ remote_dir"; 是错的,说实话,当我需要整个目录时,我有$ filename,这是我到目前为止所有的.

php sftp file

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