小编Sci*_*cis的帖子

在apache httpd反向代理和Tomcats之间进行双向SSL身份验证

我有一个Apache HTTPD作为反向代理和Tomcat(6.0.35)服务器,我想要实现的是Tomcat服务器和反向代理之间将存在相互信任.这意味着当反向代理转发请求时,它将呈现它自己的证书,该证书将被导入Tomcat的信任库文件,从而使Tomcat仅在它们真正由反向代理生成时才接受请求(如果可能,甚至可以检查tomcat的证书是否为某个特定的证书).我设法设置了一个需要客户端证书的Tomcat,它运行正常,但正确的反向代理配置似乎在逃避我.

apache ssl tomcat mod-proxy

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

Spring MVC在Tomcat 6.0.35上使用@RequestParam和RequestMethod.DELETE

我有一个简单的方法(在Tomcat 6.0.35上运行),如下所示:

@RequestMapping(value = "/bla/d", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void d(@RequestParam String d){
    //logic here
}
Run Code Online (Sandbox Code Playgroud)

当我发送一个DELETE请求,其中包含类似参数的帖子(d = gggg在正文中),我得到400 Bad Request.但如果我把它改成

@RequestMapping(value = "/bla/d", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void d(@RequestParam String d){
    //logic here
}
Run Code Online (Sandbox Code Playgroud)

它完美地运作.我正在使用Firefox附加组件来测试它(以及python和Spring的RestTemplate,结果相同)这里的请求是如何看待POST的(a是一个带有参数a的cope粘贴方法):

POST /bla/a HTTP/1.1
Host: ~~~~:8080
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 7
Pragma: no-cache
Cache-Control: no-cache
a=asdas

HTTP/1.1 204 No Content
Server: Apache-Coyote/1.1
Date: Tue, 12 Jun 2012 …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc http-delete

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

使用maven-assembly-plugin包含所需的驱动程序时找不到合适的驱动程序

可能重复:
java错误(找不到合适的驱动程序)

我有一个非常小的可以使用PostgreSQL DB,将它用作单个jar非常方便.所以我确实尝试过像这样使用maven-assembly-plugin:

<artifactId>maven-assembly-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>pack.name.MainClass</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
Run Code Online (Sandbox Code Playgroud)

它工作得很好,我可以看到我需要添加到jar文件的所有文件,包括驱动程序的文件,但是当我尝试运行它时,我得到一个:

java.sql.SQLException: No suitable driver found for jdbc:postgresql://<ip>:5432/dbname
Run Code Online (Sandbox Code Playgroud)

我有这个:

<dependencies>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
        </dependency> 
        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.1-901-1.jdbc4</version>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

在依赖项中,URL与我上面写的完全一样(除了删失地址:)).我错过了什么?

谢谢!

java postgresql jar jdbc maven

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

DateTime.Parse抛出格式异常

我通过解析XElement从xml中检索日期和时间字符串.日期和时间值分别由file.Element("Date").Value和检索 file.Element("Time").Value.

检索Date值后,我将其解析为DateTime变量

DateTime dt,ts;
dt = file.Element("Date").Value; // the value is say 12/29/2012
Run Code Online (Sandbox Code Playgroud)

然后将此dt值设置为xaml UI上的datepicker值

datepicker.Value = dt;
Run Code Online (Sandbox Code Playgroud)

我还有一个timepicker,其值必须由从xml检索的Time值设置.要设置timepicker值,请执行以下操作.声明3个字符串,说:

string a = file.Element("Time").Value; // the value is say 9:55 AM
string b = file.Element("Time").Value.Substring(0, 5) + ":00"; // eg 9:55:00
string c = file.Element("Time").Value.Substring(5); // the value is ' AM'
Run Code Online (Sandbox Code Playgroud)

然后我连接日期值和字符串'b'和'c'

string total = file.Element("Date").Value + " " + b + c;
Run Code Online (Sandbox Code Playgroud)

价值total现在是'12/29/2012 9:55:00 AM'

然后我尝试将此total字符串解析为DateTime,但它会抛出一个formatexception

DateTime.Parse(total, CultureInfo.InvariantCulture);
Run Code Online (Sandbox Code Playgroud)

任何帮助赞赏...

c# datetime-format formatexception

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

Python functools.lru_cache 驱逐回调或等效函数

是否可以定义functools.lru_cache一个项目被驱逐时的回调?在回调中还应该存在缓存的值。

如果没有,也许有人知道一个支持驱逐和回调的轻量级类似字典的缓存?

python python-3.x functools

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

在向量中使用共享指针时内存泄漏

在向向量添加共享指针时,我一直面临内存泄漏问题,向量定义如下:

vector<shared_ptr<Recipe>> favorites;
Run Code Online (Sandbox Code Playgroud)

(食谱是一个简单的类,有2个简单的字段)

以下函数用于向用户的收藏夹添加配方:

void User::postRecipe(string recipeName) {
    if (!(*this).isConnected())
        throw UserNotConnectedException();
    if (!(*this).isInGroup())
        throw NotInGroupException();
    shared_ptr<User> owner = server->seekUser((*this).getId());
    shared_ptr<Recipe> recipe(new Recipe(recipeName, owner));
    server->postRecipe((*this).groupName, recipe);
    if (!checkIfRecipeInFavs(favorites, recipeName)) {
        favorites.push_back(recipe);
}
Run Code Online (Sandbox Code Playgroud)

虽然程序编译并且程序的输出符合要求,但此函数的最后一行似乎会导致内存泄漏,如果删除它,错误就会消失.

有任何想法吗?提前致谢.

Recipe.h:

class Recipe
{
    string name;
    shared_ptr<User> owner;
public:
    Recipe(string name, shared_ptr<User> owner):name(name),owner(owner){};
    ~Recipe(){};
    string getName();
    shared_ptr<User> getOwner();
};
Run Code Online (Sandbox Code Playgroud)

Recipe.cpp:

string Recipe::getName(){
    return name;
}
shared_ptr<User> Recipe::getOwner(){
    return owner;
}
Run Code Online (Sandbox Code Playgroud)

c++ memory-leaks vector shared-ptr

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