小编Pra*_*ngh的帖子

如何使用camel-jackson将JSONArray转换为Object of List

我有如下json数组的字符串

{"Compemployes":[
    {
        "id":1001,
        "name":"jhon"
        },
        {
                "id":1002,
        "name":"jhon"
        }
]}
Run Code Online (Sandbox Code Playgroud)

我想将此jsonarray转换为List<Empolyee>.为此,我添加了maven依赖" camel-jackson"并为员工编写了pojo类.但当我尝试运行我的下面的代码

 ObjectMapper mapper = new ObjectMapper();
 List<Employe> list = mapper.readValue(jsonString, TypeFactory.collectionType(List.class, Employe.class));
Run Code Online (Sandbox Code Playgroud)

我得到以下例外.

org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token
 at [Source: java.io.StringReader@43caa144; line: 1, column: 1]
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我缺少什么或做错了什么

java json apache-camel jackson

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

如何清除选定的值selectize.js下拉列表

我有一个selectize.js下拉菜单,我必须清除所选的值.

我试过了 :

var selectize = $("#optionNetFlow")[0].selectize;
selectize.clear();
Run Code Online (Sandbox Code Playgroud)

如另一个问题中所建议的如何以编程方式设置selectize.js选项列表.但它给出了一个错误,

Uncaught TypeError: Cannot read property 'selectize' of undefinedmessage: "Cannot read property 'selectize' of undefined"stack: (...)get stack: function () { [native code] }arguments: nullcaller: nulllength: 0name: ""prototype: StackTraceGetterconstructor: function () { [native code] }__proto__: Object__proto__: function Empty() {}<function scope>set stack: function () { [native code] }__proto__: Error
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

当我把它改为:

    var selectize = $("#optionNetFlow").selectize;
    selectize.clear();
Run Code Online (Sandbox Code Playgroud)

我给出了错误:

TypeError: undefined is not a functionmessage: "undefined is not a function"stack: (...)get stack: function () { …
Run Code Online (Sandbox Code Playgroud)

javascript jquery selectize.js

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

已成功与服务器建立连接,但在登录过程中发生错误.(错误号码:233)

连接到SQL Server时出错:

在此输入图像描述

Stack Trace中的详细信息如下:

===================================

Cannot connect to ServerName.

===================================

A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) (.Net SqlClient Data Provider)

------------------------------
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=233&LinkId=20476

------------------------------
Server Name: ServerName
Error Number: 233
Severity: 20
State: 0


------------------------------
Program Location:

   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error) …
Run Code Online (Sandbox Code Playgroud)

sql-server sql-server-2008-r2

28
推荐指数
10
解决办法
11万
查看次数

无法导入wsdl:portType,wsdl:binding,wsdl:port

我在使用SVCUtil为WCF生成代理时遇到错误.错误是

Attempting to download metadata from 'net.pipe://localhost/WebServices/Mgmt.svc' using WS-Metadata Exchange. This URL does not support DISCO.
Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Referenced type 'SearchCriteria, Service.DataContracts, Version=2.5.0.0, Culture=neutral, PublicKeyToken=null
t be used since it does not match imported DataContract. Need to exclude this type from referenced types.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='IMgmt']


Error: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent …
Run Code Online (Sandbox Code Playgroud)

c# asp.net wcf proxy svcutil.exe

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

无法捕获视图层次结构

错误:无法捕获视图层次结构.详细信息:日志标题:数据源表达式执行失败.日志详细信息:误差评估表达式"(ID)[[(类)objc_getClass( "DBGTargetHub")sharedHub] performRequestWithRequestInBase64:@ "/ XxATTlNNdXRhYmxlRGljdGlvbmFyeaM + QDxcTlNEaWN0aW9uYXJ5XxAPSW5pdGlhbCByZXF1ZXN0XxAkQ0U4OUY0RkItRkRGRS00RUNGLUIwNzctMUQyNDk1REMzMjRCEAHSODlARaJAPF8QD05TS2V5ZWRBcmNoaXZlctFISVRyb290gAEACAARABoAIwAtADIANwBRAFcAXgBmAHEAeAB/AIEAgwCFAIcAiQCLAJIAlACWAJgAmgCcAJ4AoAC + AN0A9wEYATgBUgFUAVsBYAFiAWQBZgFoAW0BbwFxAXMBdQF3AY0BoQG3AdAB0gHTAdgB2QHbAeAB6wH0AfwB/wIIAg0CIwInAjQCRgJtAm8CdAJ3AokCjAKRAAAAAAAAAgEAAAAAAAAASgAAAAAAAAAAAAAAAAAAApM ="]":错误:执行被中断,原因: EXC_BAD_ACCESS(代码= 1,地址= 0x0).

该过程已返回到表达式评估之前的状态.

xcode9

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

NUnit中不支持的测试框架错误

我正在使用Visual Studio 2013进行NUnit测试.我们使用NUnitTestAdapter将NUnit的测试运行与Visual Studio集成.

Visual Studio 2013 NUnit版本="3.0.1"NUnitTestAdapter版本="2.0.0".Net Framework 4.5.2

所有包都是最新的并从Nuget安装.没有构建错误.我们在测试结果窗口中收到错误:

Attempt to load assembly with unsupported test framework in  D:\JuniorAchievement\Git\jaums\JA.UMS.Tests\bin\Debug\JA.UMS.Tests.dll
Run Code Online (Sandbox Code Playgroud)

使用Visual Studio Test Explorer运行或调试测试时.

在此输入图像描述

测试能够在Visual Studio 2013 ultimate上使用相同代码的一台计算机上运行.我们所有其他人都有Visual Studio 2013专业版,虽然我怀疑它与问题无关.

请帮忙.

更新

__________

更新到NUnit3测试适配器后没有错误,但仍未发现任何测试.

在此输入图像描述

不知怎的,两个适配器都可用,但是使用Nuget和VS扩展我只能找到NUnit3测试适配器.

https://visualstudiogallery.msdn.microsoft.com/0da0f6bd-9bb6-4ae3-87a8-537788622f2d安装的NUnit3测试适配器

c# nunit visual-studio-2013 nunittestadapter

14
推荐指数
2
解决办法
5856
查看次数

如何使用C#处理CSV文件中的换行符?

我有一个Excel电子表格在C#中转换为CSV文件,但在处理换行符时遇到问题.例如:

"John","23","555-5555"

"Peter","24","555-5
555"

"Mary,"21","555-5555"
Run Code Online (Sandbox Code Playgroud)

当我读取CSV文件时,如果记录没有以双引号(")开头,那么错误就会出现换行符,我必须将其删除.我有一些来自互联网的CSV读取器类,但我担心它们在换行时会失败.

我该如何处理这些换行符?


非常感谢大家的帮助.

heres是我到目前为止所做的,我的记录有固定的格式,一切都从一开始

JTW;...;....;...;

JTW;...;...;....

JTW;....;...;..

..;...;... (wrong record, line brak inserted)

JTW;...;...
Run Code Online (Sandbox Code Playgroud)

所以我检查了;每一行的[3]位置.如果我写的是真的,如果假病附加在最后*删除换行符)

我现在遇到问题,因为我将文件保存为txt.

顺便说一句,我通过在excell中保存为csv将excell spreadshit转换为csv.但我不确定客户是否这样做.

所以作为TXT的文件是完美的.香港专业教育学院检查了记录和总数.但现在我必须将它转换回csv,我真的很想在程序中做到这一点.有人知道吗?

这是我的代码:

namespace EditorCSV
{
    class Program
    {
        static void Main(string[] args)
        {
            ReadFromFile("c:\\source.csv");
    }


        static void ReadFromFile(string filename)
        {
            StreamReader SR;
            StreamWriter SW;
            SW = File.CreateText("c:\\target.csv");
            string S;
            char C='a';
            int i=0;
            SR=File.OpenText(filename);
            S=SR.ReadLine();
            SW.Write(S);
            S = SR.ReadLine();
            while(S!=null)
            {
                try { C = S[3]; }
                catch (IndexOutOfRangeException exception){
                    bool t = false;
                    while …
Run Code Online (Sandbox Code Playgroud)

c# csv

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

Mandrill"reject_reason":"unsigned"

我正在尝试使用mandrill电子邮件服务发送电子邮件但我收到以下错误:

[
    {
        "email": "pranav_withyou@hotmail.com",
        "status": "rejected",
        "_id": "daab0daa538a4fe9b161be709593be0b",
        "reject_reason": "unsigned"
    }
]
Run Code Online (Sandbox Code Playgroud)

我试图在javascript中使用ajax调用发送电子邮件,如:

    $.ajax({
        type: "POST",
        url: "https://mandrillapp.com/api/1.0/messages/send.json",
        data: {
            "key": "RemovedforSecurityitscorrect",
            "message": {
                "html": "<p>Example HTML content</p>",
                "text": $('#emailText').val(),
                "subject": $('#emailSubject').val(),
                "from_email": $('#fromEmail').val(),
                "from_name": $('#fromName').val(),
                "to": [{
                        "email": $('#toEmail').val(),
                        "name": $('#recipientName').val(),
                        "type": "to"
                }],
                "headers": {
                    "Reply-To": $('#fromName').val()
                }
            },
            success: function (data) {
                console.log("Email Sent");
            },
            error: function (xhr, status, error) {
                console.log("Error while sending mail");
            }
        }
    });
Run Code Online (Sandbox Code Playgroud)

所有的值都来自ajax调用并且响应中显示服务器.有什么问题?

javascript email ajax mandrill

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

[UITapGestureRecognizer标签]:发送到实例的无法识别的选择器

我正在进行一系列的imageview安排,并TapView为其分配一个识别器

UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc]
                                         initWithTarget:self action:@selector(action:)];
[tapRecognizer setNumberOfTouchesRequired:1];
[tapRecognizer setDelegate:self];
imageView.userInteractionEnabled = YES;
[imageView addGestureRecognizer:tapRecognizer];
Run Code Online (Sandbox Code Playgroud)

我已将选择器定义为:

-(void) action:(id)sender
  {
    NSLog(@"TESTING TAP");
    NSLog (@"%d",[sender tag]);
  }
Run Code Online (Sandbox Code Playgroud)

这是崩溃,我收到错误消息: -

[UITapGestureRecognizer tag]: unrecognized selector sent to instance 0x145d0210

objective-c ios4 xcode4.5

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

用新构造的DOM结构替换widget元素

<script>
(function( $ ) {

    $.widget( "my.dropbox", {
        errorText: function(text) {
            $(this.element).next().html(text);
        },

        _create: function() {
             var id = $(this.element).attr("id");
             var customDropbox = $(
                "<div class='form-group'>"+
                   "<label for='"+id+"'>"+getLabelFor(id)+"</label>"+
                   "<select id='"+id+"'></select>"+
                   "<div class='errors'></div>"+
                "</div>"
             );
             customDropbox.attr("id", id);

             $(this.element).replaceWith(customDropbox); // This removes original element from DOM

             populateOptions(id);
        },


    });

}( jQuery ));

$(document).ready(function(){
    $("#field1").dropbox(); //blank input field turns into a select with a label, populated options e.t.c..
    $("#button1").on("click", function(){
        $("#field1").dropbox("errorText", "This is a validation error message"); //throws an error saying dropbox is …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery jquery-ui widget

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