小编Ant*_*ior的帖子

GWT和Enum的问题

我在GWT应用程序的客户端部分有一个枚举,当我尝试运行与序列化问题相关的异常时,我得到一个异常.我做错了吗?我读到GWT支持枚举,我使用的是最后一个版本.

枚举:

public enum AnEnum implements Serializable {

    ITEM_A("Item a description"), ITEM_B("Item b description");

    private String description;

    private AnEnum(String description) {
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

}
Run Code Online (Sandbox Code Playgroud)

例外:

Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer(ServerSerializationStreamWriter.java:742)
    ... 47 more
Caused by: com.google.gwt.user.client.rpc.SerializationException: Type '(...).client.(...).AnEnum' was not included in the set of types which can be serialized …
Run Code Online (Sandbox Code Playgroud)

java gwt enums

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

缩放和选择不适用于具有Time类型的x轴的C#图表

我正在使用以下代码来允许选择和缩放我的图表部分:

chart1.ChartAreas[0].CursorX.IsUserEnabled = true;
chart1.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
chart1.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;

chart1.ChartAreas[0].CursorY.IsUserEnabled = true;
chart1.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
chart1.ChartAreas[0].AxisY.ScaleView.Zoomable = true;
chart1.ChartAreas[0].AxisY.ScrollBar.IsPositionedInside = true;
Run Code Online (Sandbox Code Playgroud)

它适用于具有Integer类型的x轴和y轴的图表.

在此输入图像描述

但是当我将系列值类型设置为时series1.XValueType = ChartValueType.Time;,我将无法放大x轴.

在此输入图像描述

当我为auto设置两个轴值类型并使用例如添加点时chart1.Series[0].Points.AddXY(DateTime.Now.ToLongTimeString(), rand.Next(10, 20));,则缩放工作.

如何让我的x轴成为时间并仍然可以缩放?

.net c# mschart

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

在C#中使用可变参数表示JSON的类的最佳方法

我在WCF中有一个Web服务,其操作需要JSON格式的请求和响应.我知道我可以编写具有我想用JSON表示的属性的C#对象,但我的问题是JSON参数可能会改变.例如,我的方法合同如下:

    [WebInvoke(Method = "PUT", 
        UriTemplate = "users", 
        RequestFormat = WebMessageFormat.Json, 
        ResponseFormat = WebMessageFormat.Json)]
    [OperationContract]
    Response PutUserAccount(User user);
Run Code Online (Sandbox Code Playgroud)

用户的参数可能包含任意数量的参数,因此用户的实例有时可能是:

{
    "Name" : "John",
    "LastName" : "Doe",
    "Email" : "jdoe@gmail.com",
    "Username" : "jdoe",
    "Gender" : "M"
    "Phone" : "9999999"
}
Run Code Online (Sandbox Code Playgroud)

甚至:

{
    "Name" : "John",
    "LastName" : "Doe",
    "Email" : "jdoe@gmail.com",
    "Username" : "jdoe",
    "FavoriteColor" : "Blue"
}
Run Code Online (Sandbox Code Playgroud)

使用具有可变数量属性的对象来表示JSON文档的最佳方法是什么?

编辑这个类允许我有一个灵活的JSON表示,因为我不能使用JObjectWCF(我应该发布这个作为答案吗?):

using System; 
using System.Collections.Generic; 
using System.Runtime.Serialization;

namespace MyNamespace {
    [Serializable]
    public class Data : ISerializable
    {
        internal Dictionary<string, object> …
Run Code Online (Sandbox Code Playgroud)

c# wcf json

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

使用Java控制Windows应用程序

我想知道是否有任何方法可以使用Java代码控制Windows应用程序.我已经使用Google搜索,发现可以使用JNI或名为NewJawin的库来完成.

我想使用Java代码控制Windows Media Player,例如播放,暂停和更改歌曲,但是到目前为止找不到相关的示例来启动我.你们有什么建议吗?

java windows

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

在使用jQuery发送表单数据之前对其进行操作

我想在发送到服务器之前使用jQuery加密表单中的某些数据,它可以是MD5哈希.这是一个小项目,所以我真的不需要使用SSL.

$.md5在密码确认信息中使用了以下JavaScript代码:

    $(document).ready(function() {
        var dataToSend = {};
        dataToSend['action'] = 'signup';
        dataToSend['name'] = name.val();
        dataToSend['email'] = email.val();
        dataToSend['confsenha'] = $.md5(pass2.val());

        var options = {
            target: '#error', 
            url: 'insert.php',
            beforeSubmit: validate,
            data: dataToSend,
            success: function(resposta) {
                $('#message').html(resposta);
            }
        };
        $('#customForm').ajaxForm(options); 
    });
Run Code Online (Sandbox Code Playgroud)

问题是数据是重复的.我认为通过使用var来覆盖正在发送的数据dataToSend会使得ajaxForm只发送该映射中的数据.但除了发送数据外dataToSend,它还从表单发送数据,因此我想用MD5加密的内容既加密又干净.这是请求中的内容示例:

usuario =用户电子邮件=用户%40email.com&senha = 12345&confsenha = 12345&发送=&行动=注册&名称=用户电子邮件=用户%40email.com&confsenha = d41d8cd98f00b204e9800998ecf8427e

我知道我必须定义一个函数beforeSerialize,但我不知道如何操作表单数据.谁能告诉我怎么做?

javascript jquery

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

使用PHP获取页面标题的问题

我在PHP中执行此功能以获取页面标题.我知道它可能看起来有点乱,但那是因为我是PHP的初学者.我preg_match("/<title>(.+)<\/title>/i",$returned_content,$m)之前在if中使用过它并没有像我预期的那样工作.

function get_page_title($url) {
    $returned_content = get_url_contents($url);
    $returned_content = str_replace("\n", "", $returned_content);
    $returned_content = str_replace("\r", "", $returned_content);
    $lower_rc = strtolower($returned_content);
    $pos1 = strpos($lower_rc, "<title>") + strlen("<title>");
    $pos2 = strpos($lower_rc, "</title>");
    if ($pos2 > $pos1)
        return substr($returned_content, $pos1, $pos2-$pos1);
    else
        return $url;
}
Run Code Online (Sandbox Code Playgroud)

当我尝试使用上述功能获取以下页面的标题时,我得到的是:http: //www.google.com - >"302 Moved" http://www.facebook.com - >""http ://www.facebook.com" http://www.revistabula.com/posts/listas/100-links-para-clicar-antes-de-morrer - >"http://www.revistabula.com/posts/listas/100-links-para-clicar-antes-de-morrer"(当我添加一个/到链接的末尾,我可以成功获得标题:"100链接para clicar antes de morrer | Revista Bula")

我的问题是: - 当我尝试访问google.com时,我知道谷歌会重定向到我国家的镜像,但我怎样才能获得重定向到的页面标题? - 我的功能有什么问题让它获得某些页面的标题,而不是其他页面的标题?

php

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

标签 统计

c# ×2

java ×2

.net ×1

enums ×1

gwt ×1

javascript ×1

jquery ×1

json ×1

mschart ×1

php ×1

wcf ×1

windows ×1