问题列表 - 第40219页

vps上的django - 重新启动服务器时获取“模型已注册”

周末问了这个问题,但由于某种原因,所有回复都死了。重新开始,因为我现在有了新信息

当我在我的 vps 上重新启动 apache 时,我得到

the model "category" is already registered
Run Code Online (Sandbox Code Playgroud)

来自 init.py

我认为这是因为该对象被发现并注册了两次。

我不认为这会是一个问题,它不是在我没有收到这些错误的开发中。另外,我在同步数据库后第一次运行服务器时没有收到错误消息。

所以上传代码,syncdb,启动apache,没有错误信息。重新启动 apache 并出现错误消息。

我可以通过注释掉注册模型的行来隐藏它,但这意味着该对象不会出现在管理中,除非我取消注释该行并在管理站点第一次加载后上传它。

这似乎仅在 apache 重置后第一次发生,随后不会发生。

有人遇到过这个吗?在 debian、django 1.2.3 上使用 apache 和 mod_wsgi

python django django-models

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

404的ASP.NET自定义错误页面为http状态返回302

在我的asp.net网站上,我在web.config文件中定义了以下自定义错误页面.

<customErrors mode="On" defaultRedirect="~/defaulterror.htm" >
<error statusCode="404" redirect="~/404.htm" />
Run Code Online (Sandbox Code Playgroud)

当找不到文件时它正确显示404.htm页面,但问题是当我做Fiddler跟踪它返回302作为HTTP状态代码.这是搜索引擎页面索引的一个大问题,因为这些破坏的链接仍然被索引最近因为这个在我的网站上.如何防止返回302作为文件未找到错误的HTTP状态代码,并返回404文件未找到错误.我正在使用asp.net 3.5.

.net asp.net

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

将文件作为命令行参数传递并读取其行

这是我在互联网上找到的用于读取文件行的​​代码,我也使用eclipse,并在其参数字段中将文件名称作为SanShin.txt传递.但它会打印:

Error: textfile.txt (The system cannot find the file specified)
Run Code Online (Sandbox Code Playgroud)

码:

public class Zip {
    public static void main(String[] args){
        try{
            // Open the file that is the first 
            // command line parameter
            FileInputStream fstream = new FileInputStream("textfile.txt");
            BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
            String strLine;
            //Read File Line By Line
            while ((strLine = br.readLine()) != null)   {
              // Print the content on the console
              System.out.println (strLine);
            }
            //Close the input stream
            in.close();
            }catch (Exception e){//Catch exception if any
              System.err.println("Error: …
Run Code Online (Sandbox Code Playgroud)

java command-line file

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

在简单的表上"超过锁定等待超时;尝试重新启动事务"

我已经创建了数据库表.但是有一个奇怪的事情我可以在表中插入行,但是当我想删除或更新数据库行时会抛出一个错误:

/*SQL错误(1205):超出锁定等待超时; 尝试重启事务*/

在其他表中没有错误,一切都很好.

这是一个表结构:

CREATE TABLE `cruises` (
    `id` BIGINT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `enable_text` ENUM('true','false') NOT NULL,
    `enable_file` ENUM('true','false') NOT NULL,
    `title` VARCHAR(256) NOT NULL,
    `full_text` MEDIUMTEXT NOT NULL,
    `description` VARCHAR(256) NULL,
    `date_of_departure` DATE NOT NULL,
    `number_of_nights` INT(10) UNSIGNED NOT NULL,
    `point_of_departure` VARCHAR(256) NOT NULL,
    `cruise_type` BIGINT(10) UNSIGNED NOT NULL,
    `cruises_document_id` BIGINT(10) UNSIGNED NOT NULL,
    `price` FLOAT(5,0) UNSIGNED NOT NULL,
    PRIMARY KEY (`id`),
    INDEX `FK_cruises_cruises_types` (`cruise_type`),
    INDEX `FK_cruises_cruises_documents` (`cruises_document_id`),
    CONSTRAINT `FK_cruises_cruises_documents` FOREIGN KEY (`cruises_document_id`) REFERENCES `cruises_documents` (`id`),
    CONSTRAINT …
Run Code Online (Sandbox Code Playgroud)

mysql

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

JSF 2.0:以编程方式添加UIComponent时@ResourceDependency不起作用

@ResourceDependency(library = "component/myComponent", name = "myComponent1.css")
public class MyComponent1 extends UIComponentBase {

    public void encodeBegin(FacesContext context) throws IOException {
        MyComponent2 comp2 = new MyComponent2();
        getChildren().add(comp2);
    }

}

@ResourceDependency(library = "component/myComponent", name = "myComponent2.css")
public class MyComponent2 extends UIComponentBase {

    // ...

}
Run Code Online (Sandbox Code Playgroud)

myComponent1.css被包含在页面中,myComponent2.css没有.

特征?错误?配置问题?

它有程序化的方式来添加资源可能解决这个问题吗?

运行Mojarra 2.0.2

java jsf jsf-2

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

如何在时间跨度上进行划分

我有一个值TimeSpan,让我们说:tsp1= 2小时5分钟.我有另一个TimeSpan变量,其中包含如下值:tsp2= 0小时2分钟

请告诉我如何划分tsp1,tsp2以便我可以获得tsp2分成的确切次数tsp1和剩余部分.

我正在使用Visual Studio 2008.

谢谢.

c# vb.net timespan

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

在WM_KEYDOWN中获取Unicode字符

在我需要以不同方式处理大量键的应用程序中,我想要处理WM_KEYDOWN中的所有情况,而根本不使用WM_CHAR.是否可以从WM_KEYDOWN提供的虚拟键序列中获取正确的ASCII/UNICODE字符,而不是依赖于更常规的TranslateMsg/WM_CHAR?

作为一个例子:应用程序应该能够以完全不同的方式处理Shift-B,按下CTRL-B的常规B.

使用MapVirtualKey,您不使用Shift,Control和Alt键的状态,或者至少不是我能看到的状态.

正如Leo Davidson所说:你可以使用ToUnicode调用来自己执行VK - > Unicode转换.

windows keyboard winapi

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

'('或'['预期

我在尝试编译程序时遇到以下错误.

'('或'['预期.

 public AccountArrayList()
{
    // line one below is the hi-lighted code
    ArrayList accounts = new ArrayList;
    accounts.add("1");
    accounts.add("1");
    accounts.add("1");
    accounts.add("1");
    accounts.add("1");
    accounts.add("1");
    accounts.add("1");
    accounts.add("1");
    accounts.add(5,"900");
}
Run Code Online (Sandbox Code Playgroud)

谢谢.

java arrays

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

在Windows JRE中导入StartCom CA证书

我有一个Java应用程序访问使用StartCom SSL证书的服务.为了实现这一点,我需要将StartCom CA证书添加到Java的信任库中,因为它们默认情况下不在那里.我已经使用这些命令在linux上成功完成了这项工作

sudo keytool -import -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -noprompt -alias startcom.ca -file ca.crt
sudo keytool -import -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -noprompt -alias startcom.ca.sub.class1 -file sub.class1.server.ca.crt
sudo keytool -import -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -noprompt -alias startcom.ca.sub.class2 -file sub.class2.server.ca.crt
sudo keytool -import -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -noprompt -alias startcom.ca.sub.class3 -file sub.class3.server.ca.crt
sudo keytool -import -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -noprompt -alias startcom.ca.sub.class4 -file sub.class4.server.ca.crt
Run Code Online (Sandbox Code Playgroud)

(从这个脚本)

但是,相同的命令(适当调整)在Windows上不起作用.我明白了:

keytool error: java.lang.RuntimeException: Usage error, trustcacerts is not …
Run Code Online (Sandbox Code Playgroud)

java security certificate keystore truststore

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

循环遍历ASP.NET缓存对象中的键

ASP.NET中的缓存看起来像使用某种关联数组:

// Insert some data into the cache:
Cache.Insert("TestCache", someValue);
// Retrieve the data like normal:
someValue = Cache.Get("TestCache");

// But, can be done associatively ...
someValue = Cache["TestCache"];

// Also, null checks can be performed to see if cache exists yet:
if(Cache["TestCache"] == null) {
    Cache.Insert(PerformComplicatedFunctionThatNeedsCaching());
}
someValue = Cache["TestCache"];
Run Code Online (Sandbox Code Playgroud)

如您所见,对缓存对象执行空检查非常有用.

但我想实现一个缓存清除功能,可以清除缓存值,我不知道整个密钥名称.因为这里似乎有一个关联数组,它应该是可能的(?)

任何人都可以帮我找出一种循环存储缓存键并对它们执行简单逻辑的方法吗?这就是我追求的:

static void DeleteMatchingCacheKey(string keyName) {
    // This foreach implementation doesn't work by the way ...
    foreach(Cache as c) {
        if(c.Key.Contains(keyName)) {
            Cache.Remove(c);
        }
    } …
Run Code Online (Sandbox Code Playgroud)

asp.net caching associative-array

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