小编Bob*_*ore的帖子

Eclipse热键在XFCE中不起作用

我在使用XFCE桌面的Fedora 16(64位)上使用了新安装的Eclipse indigo.但我只有大约一半的热键工作; 例如,如果我尝试用Ctrl+ F11键运行我的项目没有任何反应.

大多数组合都是如此,例如,Shift+ Ctrl+ N用于启动新项目.

有什么问题?在我以前的Ubuntu上一切正常.

java eclipse ide

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

来自web的UIDocumentInteractionController和文件

我想在其他应用程序中从Web打开文件.

我的代码:

NSURLRequest *req = [[NSURLRequest alloc] initWithURL:url];
[NSURLConnection sendAsynchronousRequest:req queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *resp, NSData *respData, NSError *error){
    NSLog(@"resp data length: %i", respData.length);
    NSArray *names = [objDict[@"name"] componentsSeparatedByString:@"."];
    NSString *fileName = [@"downloaded." stringByAppendingString:names[names.count-1]];
    NSString * path = [NSTemporaryDirectory() stringByAppendingPathComponent:fileName];
    NSError *errorC = nil;
    BOOL success = [respData writeToFile:path 
                 options:NSDataWritingFileProtectionComplete
                   error:&errorC];

    if (success) {
        UIDocumentInteractionController *documentController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]];
        documentController.delegate = self;
        [documentController presentOptionsMenuFromRect:CGRectZero inView:self.view animated:YES];
    } else {
        NSLog(@"fail: %@", errorC.description);
    }
}];
Run Code Online (Sandbox Code Playgroud)

它显示面板,但在点击任何按钮时崩溃(不仅仅是"取消").

我启用了僵尸对象,它写道:

-[UIDocumentInteractionController URL]: message sent …
Run Code Online (Sandbox Code Playgroud)

xcode cocoa-touch ios

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

为嵌入式tomcat指定自定义web.xml

使用嵌入式tomcat实例时,有没有办法指定web.xml与标准不同的方法WEB-INF/web.xml

我想web.xml在我的src/test/resources(或其他一些区域)中添加一个并web.xml在启动嵌入式tomcat时引用它.

这是我现有的启动tomcat实例的代码

tomcat = new Tomcat();
String baseDir = ".";
tomcat.setPort(8080);
tomcat.setBaseDir(baseDir);
tomcat.getHost().setAppBase(baseDir);
tomcat.getHost().setAutoDeploy(true);
tomcat.enableNaming();

Context ctx = tomcat.addWebApp(tomcat.getHost(), "/sandbox-web", "src\\main\\webapp");
File configFile = new File("src\\main\\webapp\\META-INF\\context.xml");
ctx.setConfigFile(configFile.toURI().toURL());

tomcat.start();
Run Code Online (Sandbox Code Playgroud)

我从tomcat实例启动此服务器,我想在运行单元测试时执行以下操作

  • 关闭 contextConfigLocation
  • 指定ContextLoaderListener用于设置ApplicationContext嵌入式tomcat 的父级的自定义.

可以像这样指定此文件:

File webXmlFile = new File("src\\test\\resources\\embedded-web.xml");
Run Code Online (Sandbox Code Playgroud)

编辑

太多的无奈,我意识到,无论我做什么,我无法从寻找在劝说的Tomcat WEB-INFweb.xml.似乎我必须web.xml完全忽略它并以web.xml编程方式设置项目.

我最终得到了这个配置:

用于配置测试的cucumber.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <bean id="applicationContextProvider" class="ca.statcan.icos.sandbox.ApplicationContextProvider"/> …
Run Code Online (Sandbox Code Playgroud)

spring tomcat tomcat7 embedded-tomcat-7

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

Git Bash在启动和命令方面很慢

Windows 8.1嵌入式中的启动和命令非常慢.

当我开始git bash时,它会打开1~2分钟.

我输入一个像'ls'这样的命令,它会延迟1~2分钟.

而且十壳提示也延迟了1~2分钟.

更改环境路径不起作用.

git git-bash

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

我可以获取OWIN cookie并解密它以在BeginRequest中获取它的声明吗?

我在现有网站中实现新的ASP.NET Identity 2.0 Framework使用CA的Identity Minder,它主要使用Request.ServerVariables为所有控件供电.

我要做的是使用与HTTP处理程序在BeginRequest事件中的每个请求上使用CA执行的相同变量填充请求标头,但使用新的标识提供程序.

我知道在BeginRequest事件中我有权从客户端读取cookie,我知道我可以检查OWIN cookie是否存在(名为.AspNet.ApplicationCookie),但我不知道如何解密cookie到从中得到索赔.

我也试过这样做来阅读声明:

Dim identity = CType(Thread.CurrentPrincipal, ClaimsPrincipal)
Dim claim = identity.Claims.SingleOrDefault(Function(c) c.Type = ClaimTypes.Name)
Run Code Online (Sandbox Code Playgroud)

但是,当我这样做时,我得不到任何值,所以我假设在请求管道的早期没有填充Thread.CurrentPrincipal.

但是,此代码确实有效

Dim application As HttpApplication = DirectCast(sender, HttpApplication)
Dim cookie = application.Context.Request.Cookies(".AspNet.ApplicationCookie")
If cookie Is Nothing Then
    HttpContext.Current.Request.Headers.Add("SM_SERVERSESSIONID", "NOT Logged in")
Else
    HttpContext.Current.Request.Headers.Add("SM_SERVERSESSIONID", "Logged in")
End If
Run Code Online (Sandbox Code Playgroud)

因此,考虑到我可以访问cookie,我想知道是否有任何方法可以解密它,以便我可以阅读我在其中设置的声明.

以下是我在登录页面上设置声明的方式:

Dim claims = New List(Of Claim)()
claims.Add(New Claim(ClaimTypes.Name, user.UserName))
claims.Add(New Claim(ClaimTypes.Email, user.Email))
Dim id = New ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie)
authenticationManager.SignIn(id)
Run Code Online (Sandbox Code Playgroud)

asp.net cookies httpmodule owin asp.net-identity

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

如何创建子分支?

我的git存储库有两个分支,masterbug.我想创建一个分支bug/rep.所以我跑:

git branch bug/rep
Run Code Online (Sandbox Code Playgroud)

这给出了错误:

错误:无法解析引用refs/heads/bug/rep:不是目录致命:无法锁定ref'refs/heads/bug/rep'.

如何从bug分支创建子分支,比如bug/rep?我的git版本在Mac上是2.3.2.

git branch

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

如何在 SwiftUI 中更改状态栏背景颜色

如何将状态栏背景颜色更改为不同的颜色。我正在使用 NavigationView 和 ZStack。

这是我的代码和预览

例如,我希望绿色导航栏上方的白色区域为绿色。我怎样才能改变它?

我试过的

这是我的 NavigationBar 代码:

init() {
        UINavigationBar.appearance().largeTitleTextAttributes = [
            .foregroundColor : UIColor(#colorLiteral(red: 0.8745098039, green: 0.3411764706, blue: 0, alpha: 1))]

    UINavigationBar.appearance().backgroundColor = UIColor(named: "backgroundColor")
    }
Run Code Online (Sandbox Code Playgroud)

这是我的应用程序背景颜色代码:

var body: some View {
        NavigationView {
            ZStack {
                Color("backgroundColor")
                .edgesIgnoringSafeArea(.all)
            }
            .navigationBarTitle(Text("Agenda"))
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

最后但并非最不重要的是我的场景委托代码:

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    let newAppearance = UINavigationBarAppearance()
    newAppearance.configureWithOpaqueBackground()
    newAppearance.backgroundColor = .black
    newAppearance.titleTextAttributes = [.foregroundColor: UIColor.white]

    UINavigationBar.appearance().standardAppearance = newAppearance

    //Other code for displaying the first screen …
Run Code Online (Sandbox Code Playgroud)

ios swift swiftui

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

带有OWIN OAuth承载令牌的Web Api 2

我正在使用Visual Studio 2013构建web api,并希望使用OWIN中间件和持有者令牌进行身份验证.但是我已经有了一个数据库,并且不想使用Microsoft的新Identity框架作为它自动生成的大多数表和列,我根本不需要.

任何人都可以指出我如何应用此类身份验证的正确方向,无需使用Microsoft身份框架?

oauth asp.net-web-api owin asp.net-identity

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

Spring REST 模板接受标头

在对我们的一项 REST 服务进行一些负载测试期间,当负载增加时,我们开始看到 Spring 的 REST 模板的这些类型的日志:

在并发负载下,3-4小时后,http请求的Accept头变成

DEBUG: org.springframework.web.client.RestTemplate - Setting request Accept header to [text/plain, application/json, application/*+json, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain,<and so on>, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, …
Run Code Online (Sandbox Code Playgroud)

java rest spring spring-mvc resttemplate

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

req.body在服务器端未定义

我正在研究在服务器端使用node,express,mysql的 app .我已经在server.js文件上写了几个API,当我试图使用Postman访问那些时,req.body总是未定义的.

这是我的server.js配置.

var express = require('express');
var mysql = require('mysql');
var cors = require('cors');
var bodyParser = require('body-parser');
var wrench = require("wrench");
var fs = require('fs');
var path = require("path");
var mkdirp = require('mkdirp');
var walk = require('walk');
var fse = require('fs-extra');
var multipart = require('connect-multiparty');
var multipartMiddleware = multipart();
var crypto = require('crypto');

app.use(cors());

app.use(bodyParser.urlencoded({limit: '50mb',extended: false}));
app.use(bodyParser.json({limit: '50mb'}));

var connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'pass',
    database: 'dbname'
});


connection.connect(function(err) { …
Run Code Online (Sandbox Code Playgroud)

node.js express body-parser

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