问题列表 - 第22425页

为什么.NET中的ceiling返回Double而不是整数?

正如解释在这里,Math.Ceiling返回:"最小的积分值大于或等于".但后来它说:"请注意,此方法返回Double类型而不是整数类型." 我只是想知道为什么?

.net c# math

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

在进入ASP.NET之前是否有必要了解C#?

在参加ASP.Net编程课程之前,我是否需要获得一些C#课程?

c# asp.net

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

在Objective-C++中使用C++类

我在Cocoa应用程序中使用一个小的C++库(atm只是一个非常简单的例子来学习我应该怎么做).

所以我在命名空间中有一个小的C++类,如下所示:

namespace testlib {
class Test {
public:
    Test(unsigned a);
    Test operator+(const Test& other) const;
    Test operator+(unsigned other) const;
    Test& operator+=(unsigned other);
    Test& operator+=(const Test& other);
    unsigned getValue() const;
private:
    unsigned theValue;
};
}
Run Code Online (Sandbox Code Playgroud)

然后我有一个带有以下代码的.h文件:

#import <Foundation/Foundation.h>
#import "testlib.h"

@interface test : NSObject {
     testlib::Test* testClass;
}

- (id)init;
- (id)add: (unsigned)value;
- (unsigned)value;
- (void)dealloc;

@property void* testClass;

@end
Run Code Online (Sandbox Code Playgroud)

最后一个实现(在一个名为test.mm的文件中):

#import "test.h"

@implementation test

@synthesize testClass;

- (id)init {
 testClass = new testlib::Test(0);
 return self;
}

- (void)dealloc …
Run Code Online (Sandbox Code Playgroud)

c++ objective-c objective-c++

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

我可以使用CSS在视口中垂直居中固定高度的DIV吗?

我们有一个登录页面,旨在将200px高的DIV垂直居中在页面中间.也就是说,无论浏览器窗口的大小如何,它都会创建一个200像素的蓝色条带左边缘到右边缘(其中包含表单元素),理想情况下应该在视口中保持垂直居中.

这必须是CSS解决方案.

那么让我们说这里是一些示例标记:

<body>
    <div id="mainDiv">
       <div id="centerDiv" style="height:200px;background-color:blue;color:white">
           Center this baby vertically in the #mainDiv, please!
        </div>
    </div>
</body>
Run Code Online (Sandbox Code Playgroud)

假设我的CSS指示#mainDiv被拉伸以覆盖视口顶部和底部,这很容易做到.是否有CSS规则,我可以应用于任何元素或可靠和跨浏览器(包括IE6)垂直居中的页面#centerDiv?在完美的世界中,我们应该能够说出来

#centerDiv {
  margin: auto 0;
}
Run Code Online (Sandbox Code Playgroud)

即使在一个好的世界中,我们也应该能够用一些风格解决这个问题.但是要引用Ving Rhames的"低俗小说"中的人物,我们相当不错.

我查看了相关问题中提供的解决方案并搜索了网络.我找不到真正有效的100%.也许这是无法解决的,但我想我会在这里集体绞尽脑汁,看看能不能幸运.提前致谢.

html css

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

无法在Spring Security中使用Spring LDAP

我想根据我们的AD验证用户,所以我知道我需要spring security和spring ldap.

这是我的POM中的内容:

<groupId>org.springframework.security</groupId>
<artifactId>org.springframework.security.core</artifactId>
<version>3.0.0.RELEASE</version>
</dependency>
...
<dependency>
    <groupId>org.springframework.ldap</groupId>
    <artifactId>spring-ldap</artifactId>
    <version>1.3.0.RELEASE</version>
    <type>pom</type>
    <scope>provided</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

以下是我的secruity-context中的相应条目:

<ldap-authentication-provider user-dn-pattern="CN=0},OU=CAN,OU=NOT,OU=TELL,OU=YOU"/>
    ..  
<!-- LDAP Security Configuration -->
<ldap-server url="ldap://10.9.1.1:389/DC=TELL,DC=YOU"/>
Run Code Online (Sandbox Code Playgroud)

但是,当我运行我的应用程序使用:

mvn jetty:run
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

If you are using LDAP with Spring Security, please ensure that you include the spring-ldap jar file in your application; nested exception is java.lang.ClassNotFoundException: org.springframework.ldap.core.support.BaseLdapPathContextSource:
java.lang.ClassNotFoundException: org.springframework.ldap.core.support.BaseLdapPathContextSource
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
    at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
    at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274)
    at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:375)
    at …
Run Code Online (Sandbox Code Playgroud)

java spring maven-2 spring-security spring-ldap

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

正则表达式可以使用不同的语言吗?

当然,英语对于正则表达式来说是明智之举,因为它最初是为/开发的:

正则表达式能理解这个字符集吗?

法语进入一些重音字符,我不确定如何匹配 - 即è和e都被正则表达式视为单词字符?

Les表达régulièrespeuventcomprendre ce jeudecaractères?

日语不包含我所知的正则表达式字符以匹配.

正规表现は,この文字を理解でき,设定?

regex unicode internationalization

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

如何清除connectiontrings的configurationmanager缓存

我试图在运行时更改位于Servicehost的App.Config中的connectionstring中的数据库名称,然后在连接到另一个数据库后重新启动它.这样可以正常工作,但前提是应用程序关闭多秒钟.关闭应用程序几秒钟似乎清除了ConfigurationManager.Connectionstrings的缓存.问题是由于这个需要的关机时间,我不能在我的应用程序中使用Application.Restart().

这种缓存行为的奇怪之处在于,即使在内存中更新了值(在第二次请求时的示例中),也会正确显示更新后的值.但是当应用程序重新启动时,旧值似乎重新出现.

要验证行为,请创建新的控制台应用程序.

添加App.Config文件

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
    <add name="DomainDBConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=InitialDBName;Integrated Security=SSPI;" />
  </connectionStrings>
</configuration>
Run Code Online (Sandbox Code Playgroud)

然后将以下代码添加到Main方法

        ConfigurationManager.RefreshSection("connectionStrings");
        DbConnectionStringBuilder builder = new DbConnectionStringBuilder();
        Configuration appConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        builder.ConnectionString = appConfig.ConnectionStrings.ConnectionStrings["DomainDBConnectionString"].ConnectionString;

        //print initial value
        Console.WriteLine("initial " + (string)builder["Initial Catalog"]);

        //change value
        builder["Initial Catalog"] = "ChangedDatabaseName";
        appConfig.ConnectionStrings.ConnectionStrings.Remove("DomainDBConnectionString");
        appConfig.ConnectionStrings.ConnectionStrings.Add(new ConnectionStringSettings("DomainDBConnectionString", builder.ConnectionString));
        appConfig.ConnectionStrings.SectionInformation.ForceSave = true;
        appConfig.Save(ConfigurationSaveMode.Full);
        ConfigurationManager.RefreshSection("connectionStrings");

        Console.ReadLine();

        DbConnectionStringBuilder builder2 = new DbConnectionStringBuilder();
        Configuration appConfig2 = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        builder2.ConnectionString = appConfig.ConnectionStrings.ConnectionStrings["DomainDBConnectionString"].ConnectionString;
        Console.WriteLine("changed " + (string)builder2["Initial Catalog"]);

        Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)

要重现此行为,您需要运行应用程序(通过按F5)并关闭它.之后,solutionname.exe.config文件将显示修改后的值.如果您再次运行该应用程序(这次双击solvename.exe),如果您在终止应用程序后立即执行此操作,或者等待几秒钟后,您会发现行为上的差异.

在我看来,由于ConfigurationManager.RefreshSection("connectionStrings"),应该重新读取configsection; 但似乎这不像宣传的那样有效.

.net configurationmanager connection-string runtime

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

如何使用tomcat为容器管理的安全性配置JDBC领域?

我想配置tomcat /我的Web应用程序以使用JDBC领域来实现容器管理的安全性.我在tomcat的server.xml文件中指定了这个领域,如下所示:

<Realm className="org.apache.catalina.realm.JDBCRealm" driverName="net.sourceforge.jtds.jdbc.Driver" connectionURL="jdbc:jtds:sqlserver://hostname:1433/intranet;user=sa;password=sa04jT14;instance=instanceName" userTable="users" userNameCol="username" userCredCol="password" userRoleTable="roles" roleNameCol="role" />
Run Code Online (Sandbox Code Playgroud)

我创建了数据库和表.我创建了一个登录页面,并将以下代码添加到web.xml:

<login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
        <form-login-page>/login.xhtml</form-login-page>
        <form-error-page>/login.xhtml</form-error-page>
    </form-login-config>
</login-config>
Run Code Online (Sandbox Code Playgroud)

但Tomcat如何知道他必须使用哪个领域进行身份验证?我是否必须在元素中添加元素?但那么价​​值应该是什么呢?

提前致谢.

tomcat web.xml realm

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

javascript太多的递归?

我正在尝试创建一个脚本,在数据输入数据库后自动开始上传(我需要数据库用来上传文件的autoId).

当我运行javascript脚本运行php文件但它无法调用其他php来上传文件.

too much recursion
setTimeout(testIfToegevoegd(),500); 
Run Code Online (Sandbox Code Playgroud)

给出错误的脚本

send("/projects/backend/nieuwDeeltaak.php",'deeltaakNaam='+f.deeltaaknaam.value+'&beschrijving='+
                        f.beschrijving.value+'&startDatum='+f.startDatum.value+'&eindDatum='+f.eindDatum.value
                        +'&deeltaakLeider='+f.leiderID.value+'&projectID='+f.projectID.value,id);

                    function testIfToegevoegd(){

                        if(document.getElementById('resultaat').innerHTML == "<b>De deeltaak werd toegevoegd</b>"){
                            //stop met testen + upload file 

                            document.getElementById('nieuwDeeltaak').target = 'upload_target';
                            document.forms["nieuwDeeltaak"].submit()
                        }else{
                            setTimeout(testIfToegevoegd(),500);
                        }

                    }

                    testIfToegevoegd();
Run Code Online (Sandbox Code Playgroud)

抱歉我们必须使用荷兰语,这是一个学校项目.

当我点击第二次调用所有这些的按钮(错误之后)它工作正常.

javascript php ajax

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

binary_search,find_if和<functional>

std::find_if在其中一个重载函数中获取谓词.Binders可以为用户定义的类型编写EqualityComparators,并将它们用于动态比较或静态比较.

相比之下,标准库的二进制搜索功能采用比较器和a const T&应该用于比较的值.这感觉与我不一致,并且可能更低效,因为每次都必须使用两个参数调用比较器而不是将常量参数绑定到它.虽然有可能以std::binary_search某种方式实现,std::bind但这需要所有比较器继承std::binary_function.我见过的大多数代码都没有这样做.

比较器std::binary_function在使用算法时是否可以继续使用算法const T&而不是让我使用绑定器?是否有理由不在这些函数中提供谓词重载?

c++ stl std

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