在Phonegap / cordova Android APP中使用内容安全策略连接REST API的正确方法是什么(What is the right way of connect to a REST API with content security policy in a Phonegap/cordova Android APP)

我已经成功开发了一个Phonegap混合应用程序,它在模拟器上运行良好但在安装在Android设备上时无法发布到远程服务器。 我配置了白名单插件,我的config.xml包含

 <plugin name="cordova-plugin-whitelist" version="1" />   
 <access origin="*"/>
<allow-navigation href="http://*/*"/>
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
    <allow-intent href="market:*" />
</platform>
<platform name="ios">
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
</platform>

我的索引页面包含

 <meta http-equiv="Content-Security-Policy" content="default-src 'self' gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src *; connect-src *">

我正在使用Cordova 5.3.3,但似乎没有任何效果。

请任何人告诉我我做错了什么。 谢谢


I have successfully developed a Phonegap hybrid App, it worked well on emulators but unable to post to a remote server when installed on android device. I configured white list plugin and my config.xml contains

 <plugin name="cordova-plugin-whitelist" version="1" />   
 <access origin="*"/>
<allow-navigation href="http://*/*"/>
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
    <allow-intent href="market:*" />
</platform>
<platform name="ios">
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
</platform>

and my index page contains

 <meta http-equiv="Content-Security-Policy" content="default-src 'self' gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src *; connect-src *">

I am using Cordova 5.3.3 but yet nothing seems to work.

Please can anybody tell me what I am doing wrong. Thanks


原文:https://stackoverflow.com/questions/35644815
2023-03-16 07:03

满意答案

将泛型参数移动到接口而不是方法:

public interface ITableData<T> where T : TableData
{
    List<T> ListAll();
    void Insert(Object o);
}

public class BookData : ITableData<Book>
{
    public List<Book> ListAll()
    {
        List<Book> bookList =XXXXXX;
        //some code here
        return bookList;
    }
}

Move the generic argument to the interface instead of on the method:

public interface ITableData<T> where T : TableData
{
    List<T> ListAll();
    void Insert(Object o);
}

public class BookData : ITableData<Book>
{
    public List<Book> ListAll()
    {
        List<Book> bookList =XXXXXX;
        //some code here
        return bookList;
    }
}

相关问答

更多

包装时间通用功能(Wrapper to time generic function)

你的ExecuteTimedFunction方法看起来像这样: public void ExecuteTimedFunction(Action action, string name) { Console.Write(name); var watch = Stopwatch.StartNew(); action(); watch.Stop(); Console.WriteLine("... finished in: {0} s", watch.Elapsed...

接口实现和通用功能(Interface implementation and common function)

听起来你想要一个实现通用功能的抽象类,但仍然有两个具体的类用于不同的功能。 您可能也可能不想保留界面。 所以选项是: Interface ^ | Abstract class ^ / \ Concrete Concrete class 1 class 2 要不就 Abstract clas...

带开关的通用功能(Generic function with switch)

在我使用通用模式之前,我想知道你是否不能只使用已经符合所有浮点类型的现有FloatingPoint协议: extension FloatingPoint { var direction: String { let value = ((self - 32 / 360) * 16 / 360).rounded() switch value { case 0: return "N" case 1: return "NNE" ...

用于简化代码的通用功能(generic function for simplified code)

这一切似乎有点模糊和复杂,但要直接回答你的问题 - 为了泛化你的PopulateAddressObject函数,你可以这样做: private TPopulateAddressObject(object o, DataRow dataRow, Type type, string idColumnName) where T : IDataStorable, new() { IDataStorable instance = (IDataStorable)AppDomain.CurrentDom...

通用功能接口(Generic functional interface)

试试看: @FunctionalInterface interface TwoArgumentFunction<T, K, V> { T doJob(K arg1, V arg2); } //I know I've ommited return value in that case public <T, K, V> T runLongAction(final TwoArgumentFunction<? extends T, ? super K, ? super V> a...

通用功能签名(Generic function signatures)

您可以在F#中定义相同的界面,如下所示: type ISerializer = abstract ContentType : string abstract Serialize : obj -> string abstract Deserialize<'a> : string -> 'a 没有办法使用自然的功能数据类型(如记录)获得相同的“内部”多态性,因此您必须使用OO结构。 如果您真的想要使用记录,可以为Deserialize定义一个包装Deserialize并将其放...

C#试图简化通用类型接口的通用扩展功能(C# trying to simplify Generic Extension Function for Generic Typed Interface)

我不明白为什么你需要两个通用参数。 只需使用一个: public static class Extensions { public static void ProcessContext<TContext>(this IHasContext<TContext> t) where TContext : class { //... } } 然后推理应该工作得很好: var obj = new SomeClass(); obj.ProcessContext(); 两者之间存在一...

半通用功能(Semi-generic function)

使用sfinae template<typename> struct restrict { }; template<> struct restrict<string> { typedef void type; }; template<> struct restrict<int> { typedef void type; }; template <typename T> typename restrict<T>::type foo(T bar); 那个foo只能接受T string或int 。 ...

返回Java 8中的通用功能接口(Return generic functional interface in Java 8)

查看方法的签名,并尝试告诉确切的返回类型: static <P, Q, H extends Finder<P, Q>> H condition3(… Lambdas只能在编译时实现已知的interface 。 但编译器不知道H的实际类型参数。 你的第一种方法是有效的,因为它返回了lambda可以实现的类型Finder<P, Q> ,你的第二种方法是有效的,因为它不使用lambda来实现返回类型H extends Finder<P, Q> 。 只有第三种方法尝试为类型参数指定lambda表达式H ...

与通用功能的接口(Interface with generic function)

将泛型参数移动到接口而不是方法: public interface ITableData<T> where T : TableData { List<T> ListAll(); void Insert(Object o); } public class BookData : ITableData<Book> { public List<Book> ListAll() { List<Book> bookList =XXXXXX; //...

相关文章

更多

phonegap分享到微信插件(安卓版)

首先,请下载插件包。本插件支持phonegap3.0以上版本 http://pan.baidu.co ...

phonegap与微信开放平台接口整合

在开发phonegap应用的过程中有个需求需要将应用的消息推送到微信上。于是我自己写了一个微信的pho ...

phonegap分享到微信插件(iOS版)

这不是我的原创,只是对一款优秀的插件做一个分享和注释的工作_ 感谢原作者的辛勤劳动。 插件git地址 ...

传说中的WeixinJSBridge和微信rest接口

直接上图,金山的APP“微信导航”,从界面上看有粉丝数等关键数据,实现了直接关注功能,莫不是rest接 ...

怎么用spring security?

我正在学习spring security,看了网上的文档后(下面的附件),动手试了下,结果报错了,不知 ...

Spring Data: a new perspective of data operations

Spring Data: a new perspective of data operations ...

Stack Overflow Architecture Update - Now At 95 Million Page Views A Month

A lot has happened since my first article on theSta ...

android 集成所有分享平台

注意: 本文介绍的是Share SDK 2.x版本的集成流程和注意事项,对于Share SDK 1.x ...

Becoming a data scientist

Data Week: Becoming a data scientist Data Pointed, ...

A Great List of Windows Tools

Windowsis an extremely effective and a an efficient ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本