问题列表 - 第36700页

javascript document.cookie遗漏了一些对

我的脚本设置了10个cookie,浏览器成功保存了它们,但document.cookie只检索了9对,缺失的对如下:

auth:4ae9Mq1j6tjt7dV6kV6A0piHB6NnNjijBmecax9mA8cfDpSs6pnAcD7H1%2FUqWMIIB%2BbgtKIJ2w1L2GnXkgV2
Run Code Online (Sandbox Code Playgroud)

发生了什么?是否有字符限制document.cookie?cookie域与所有其他域相同.

javascript cookies

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

在Java中继承静态变量

我想要进行以下设置:

abstract class Parent {
    public static String ACONSTANT; // I'd use abstract here if it was allowed

    // Other stuff follows
}

class Child extends Parent {
    public static String ACONSTANT = "some value";

    // etc
}
Run Code Online (Sandbox Code Playgroud)

这在Java中可行吗?怎么样?如果我可以避免它,我宁愿不使用实例变量/方法.

谢谢!

编辑:

常量是数据库表的名称.每个子对象都是一个迷你ORM.

java polymorphism inheritance static static-variables

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

LINQ + TransactionScope不会更改SQL Server Profiler中的隔离级别

我正在使用以下格式使用linq将更改提交到我的数据库.

Begin Transaction (Scope Serialized, Required)
    Check Business Rule 1...N
    MyDataContext.SubmitChanges()
    Save Changes Done In Previous Query To Log File
End Transaction Scope
Run Code Online (Sandbox Code Playgroud)

但是在SQL Server探查器中,我在Connection:Start中看到以下行.

set transaction isolation level read committed
Run Code Online (Sandbox Code Playgroud)

我经历了这个(http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/93a45026-0425-4d49-a4ac-1b882e90e6d5)并认为我得到了答案;

直到我在Microsoft Connect上看到这个(https://connect.microsoft.com/VisualStudio/feedback/details/565441/transactionscope-linq-to-sql?wa=wsignin1.0).

有人可以告诉我,我的代码是否实际在序列化隔离级别下执行,或者它是否只是在read committed下运行?

transactions sql-server-profiler isolation-level sql-server-2008 linq-to-sql

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

为什么向下拆箱会导致异常?

我不明白,为什么下面的代码会导致异常?

static class Utility<T>
{
    public static TReturn Change<TReturn>(T arg)
    {
        object temp = arg;
        return (TReturn)temp;
    }
}

class Program
{
    static void Main(string[] args)
    {
        int i = 100;

        try
        {
            short s = Utility<int>.Change<short>(i);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

编辑:

我认为我的代码可以简化如下:

class Program
{
    static void Main(string[] args)
    { 
        int x = 100;
        object o = x;
        short s = (short)o;
    }
}
Run Code Online (Sandbox Code Playgroud)

c#

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

在Commodore 64 BASIC中选择随机字符串

我的程序上有这个变量声明:

X="MAGENTA"
Y="CYAN"
Z="TAN"
A="KHAKI"
Run Code Online (Sandbox Code Playgroud)

现在我想要的是随机选择其中一个和PRINT它.但是怎么做呢?

string random basic commodore

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

我可以创建一个PHP"宏"(如#define)来为函数调用提供参数吗?

我所讨论的参数是- __FILE____LINE__函数调用者的参数,以便函数可以在错误报告中使用它们.

假设我my_func()在file_2.php中有两个文件和第100行file_1.php调用

我想打电话my_func(__FILE__, __LINE__),如果my_func遇到错误,可以在第100行报告file_1.php.

我这样做,因为有数百个调用my_func和报告错误在my_func()本身可能没有提供信息(除非我转储堆栈).而且我不想手动输入这两个参数几百次.

CI会做类似的事情#define MY_FUNC my_func(__FILE, __LINE) - 我可以在PHP中做类似的事吗?

php macros

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

Windows编程中不同的char类型

最近,我在windows平台上遇到了关于char/string的一些任务.我看到它们是不同的char类型,如char,TCHAR,WCHAR,LPSTR,LPWSTR,LPCTSTR.有人能给我一些有关它的信息吗?以及如何使用常规char和char*.我对这些类型感到困惑?

最好的祝福,

c c++

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

document.getElementById('id')是null javascript错误

出于某种原因,我document.getElementById('id') is null在第7行得到了一个带有以下标记和脚本的JS错误:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Quadratic Root Finder</title>
<script>
document.getElementById('calculate').onclick = function calculateQuad()
{
    var inputa = document.getElementById('variablea').value;
    var inputb = document.getElementById('variableb').value;
    var inputc = document.getElementById('variablec').value;

    root = Math.pow(inputb,2) - 4 * inputa * inputc;
    root1 = (-inputb + Math.sqrt(root))/2*inputa
    root2 = (-inputb + Math.sqrt(root))/2*inputa 

    document.getElementById('root1').value = root1;
    document.getElementById('root2').value = root2;
    if(root<'0')
    {
        alert('This equation has no real solution.')
    }
    else {
        if(root=='0')
        {
            document.getElementById('root1').value = root1
            document.getElementById('root2').value = 'No Second Answer' …
Run Code Online (Sandbox Code Playgroud)

javascript null

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

使用Qt获得系统空闲时间

我几周前就是Qt的新手.我正在尝试用C++重写一个C#应用程序,并且现在有很大一部分.我目前面临的挑战是找到一种检测系统空闲时间的方法.

使用我的C#应用​​程序,我从某处看起来像这样的代码:

public struct LastInputInfo
{
    public uint cbSize;
    public uint dwTime;
}

[DllImport("User32.dll")]
private static extern bool GetLastInputInfo(ref LastInputInfo plii);

/// <summary>
/// Returns the number of milliseconds since the last user input (or mouse movement)
/// </summary>
public static uint GetIdleTime()
{
    LastInputInfo lastInput = new LastInputInfo();
    lastInput.cbSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(lastInput);
    GetLastInputInfo(ref lastInput);

    return ((uint)Environment.TickCount - lastInput.dwTime);
}
Run Code Online (Sandbox Code Playgroud)

我还没有学会如何通过DLL Imports或C++等价物引用Windows API函数.老实说,如果可能,我宁愿避免使用它们.此应用程序也将在未来转向Mac OSX和Linux.

有没有Qt特定的,与平台无关的方式来获得系统空闲时间?意味着用户没有触摸鼠标或任何键的X时间.

提前感谢您提供的任何帮助.

c# winapi qt cross-platform dllimport

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

在Java中将HTML转换为纯文本

我需要将HTML转换为纯文本.我对格式化的唯一要求是在纯文本中保留新行.新行不仅应显示在<br>其他标签的情况下,例如<tr/>,也应显示</p>新行.

用于测试的示例HTML页面是:

请注意,这些只是随机网址.

我已经尝试了在这个StackOverflow问题的答案中提到的各种库(JSoup,Javax.swing,Apache utils)来将HTML转换为纯文本.

使用JSoup的示例:

public class JSoupTest {

 @Test
 public void SimpleParse() {
  try {
   Document doc = Jsoup.connect("http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Java/Chapter09/scannerConsole.html").get();
   System.out.print(doc.text());

  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
 }
}
Run Code Online (Sandbox Code Playgroud)

HTMLEditorKit示例:

import javax.swing.text.html.*;
import javax.swing.text.html.parser.*;

public class Html2Text extends HTMLEditorKit.ParserCallback {
 StringBuffer s;

 public Html2Text() {}

 public void parse(Reader in) throws IOException {
   s = new StringBuffer();
   ParserDelegator delegator = new ParserDelegator();
   // the …
Run Code Online (Sandbox Code Playgroud)

java parsing plaintext htmleditorkit jsoup

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