杰克逊序列化长x = 1234到{x:1234}由于几个原因,我需要{x:"1234"}
任何杰克逊注释?
谢谢.
使用RPC和Java Generics发送对象列表时,我们遇到SerializationException错误.
我正在创建此小部件以显示错误:
public class Test<T> {
ListDataProvider<T> ldp = new ListDataProvider<T>();
public void setItems(List<T> list){
for(T t :list){
ldp.getList().add(t);
}
}
public List<T> getItems(){
return ldp.getList();
}
}
Run Code Online (Sandbox Code Playgroud)
这是用于创建Test小部件并传递POJO列表的代码(其中ExporterFormKey是POJO对象)
List<ExporterFormKey> list = new ArrayList<ExporterFormKey>();
ExporterFormKey key = new ExporterFormKey();
key.setKey("key1");
list.add(key);
Test<ExporterFormKey> test = new Test<ExporterFormKey>();
test.setItems(list);
Run Code Online (Sandbox Code Playgroud)
最后,下一个代码抛出一个SerializationException:
service.sendList(test.getList(), new AsyncCallback...);
Run Code Online (Sandbox Code Playgroud)
虽然下一个很好:
service.sendList(list, new AsyncCallback...);
Run Code Online (Sandbox Code Playgroud)
- - -编辑 - -
我发现做下一个代码也有效
List<ExporterFormKey> newList = new ArrayList<ExporterFormKey>();
newList.add(test.getItems().get(0));
service.sendList(newList , new AsyncCallback...);
Run Code Online (Sandbox Code Playgroud)
或者这也有效
List<ExporterFormKey> newList = new ArrayList<ExporterFormKey>(test.getItems());
Run Code Online (Sandbox Code Playgroud)
我也发现测试工作的这个变化!
public …Run Code Online (Sandbox Code Playgroud) 我有一些来自日期和长类型和叠加类型的错误.两者都使用long,这在GWT JSNI中是不允许的.日期通过getTime()序列化.
我现在正在做的事情(似乎有效)是:
来自JAVA(使用Jackson序列化为json)
Long myLong = new Long(50)
Date myDate = new Date();
public String getMyLong()
{
return String.valueOf(myLong);
}
public String getDate() {
return String.valueOf(date.getTime());
}
Run Code Online (Sandbox Code Playgroud)
FROM GWT(使用OverlayTypes)
/*Returning a Long*/
private final native String _getEscaletaId() /*-{ return this.escaletaId; }-*/;
public final Long getEscaletaId() {return new Long(_getEscaletaId());}
/*Returning a Date*/
private final native String _getDate() /*-{ return this.date; }-*/;
public final Date getDate() {return new Date(Long.valueOf(_getDate()));}
Run Code Online (Sandbox Code Playgroud)
这是处理长期和其他特殊类型的更好方法吗?
谢谢.
我有一个几乎不引人注意但又烦人的随机故障补间演员与补间引擎.演员只是一个有图像的组.补间只是从屏幕右侧到左侧并重复的线性.
FPS总是显示60.
任何的想法?
这是代码:
public class BackgroundScreen extends AbstractScreen {
public BackgroundScreen() {
stage = new Stage();
stage.setViewport(Properties.VIRTUAL_WIDTH, Properties.VIRTUAL_HEIGHT, false);
createRock();
}
private void createRock() {
rock = new GameElement(atlas.createSprite("obj-stone"));
rock.setX(Properties.VIRTUAL_WIDTH);
rock.setY(100);
float duration=5f;
Tween.to(rock, ActorAccessor.POSITION_XY, duration/2).ease(Linear.INOUT).target(-rock.getWidth(), rock.getY()).repeat(Tween.INFINITY, 0).start(Resources.tweenManager);
stage.addActor(rock);
}
@Override
public void render(float delta) {
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
Resources.tweenManager.update(delta);
stage.act(delta);
stage.draw();
}
}
Run Code Online (Sandbox Code Playgroud)
UPDATE
这是具有效果的YouTube视频的链接.两个考虑:
http://www.youtube.com/watch?v=0pVJbGFciyo
a)当屏幕记录视频时,你可以观看的时候更加明显.b)我在Galaxy Nexus上看不到任何故障.c)我只使用libgdx动作做同样的补间,故障是相同的d)不知怎的,它与我的电脑有关.
我知道复合索引是这样定义的:
db.products.ensureIndex( { "item": 1, "stock": 1 } )
Run Code Online (Sandbox Code Playgroud)
并散列一个像这样的简单索引:
db.active.ensureIndex( { item: "hashed" } )
Run Code Online (Sandbox Code Playgroud)
问题是如何实现两者?
有没有办法可以使用我的 config.properties 中的 boolean securityEnabled 禁用全局方法安全性?还有其他方法吗?
@EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled=true)
@PropertySource("classpath:config.properties")
public class SecurityConfig
extends WebSecurityConfigurerAdapter {
@Value("${securityconfig.enabled}")
private boolean securityEnabled;
...
}
Run Code Online (Sandbox Code Playgroud) 这张图片正在显示,但无论我使用的宽度或高度值如何,我都无法调整大小.你有什么?谢谢.
<ui:with field='res' type='com.hellomvp.client.resources.MyResources'/>
<ui:style>
.fortaImage { width:'50px'; height:'50px';}
</ui:style>
<g:DockLayoutPanel unit='EM'>
<g:north size="10">
<g:FlowPanel>
<g:Image styleName='{style.fortaImage}' resource='{res.fortaLogo}'/>
<g:InlineLabel>FortaService</g:InlineLabel>
<g:ListBox></g:ListBox>
<g:InlineLabel>DateIn</g:InlineLabel>
<d:DateBox></d:DateBox>
<g:InlineLabel>DateOut</g:InlineLabel>
<d:DateBox></d:DateBox>
<g:Button>Cerca</g:Button>
</g:FlowPanel>
</g:north>
</g:DockLayoutPanel>
Run Code Online (Sandbox Code Playgroud) 我在EventBus的一个真正的SimpleEventBus实现上有一些问题:我有一个活动,它也是特定事件的处理程序.此事件由服务触发.
代码:
@Mock private AssetCellList view;
@Mock private AcceptsOneWidget panel;
@Mock private SelectionModel<Asset> selectionModel;
@Mock private HasData<Asset> cellList;
@Mock private AssetService service;
@Mock private Asset asset;
@Mock private List<Asset> list;
@Mock private AssetListDTOClientImpl assetDTO;
@Mock private AssetEvent event;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
@Test
public void test(){
/*Some stubbing*/
when(view.getSelectionModel()).thenReturn(selectionModel);
when(view.getList()).thenReturn(cellList);
when(assetDTO.getAssetList()).thenReturn(list);
when(assetDTO.getAssetList().get(anyInt())).thenReturn(asset);
when(event.getAssetDTO()).thenReturn(assetDTO);
/*Creatin the Real EventBus*/
EventBus eventBus = new SimpleEventBus();
/*Creating the activity */
AssetListActivity activity = new AssetListActivity(eventBus,
view,
service);
/*Spying the …Run Code Online (Sandbox Code Playgroud) 我们正在使用带有RPC服务返回列表的IE8恶梦,其中包含(或多或少)60个对象,每个对象有5个属性.虽然现代浏览器可以完成这项工作,但IE8的响应能力还不够.关于这一点甚至存在一个公开的问题.
我们计划为需要发送大型对象列表的服务更改RPC,但我们希望更改服务器和客户端上可能的最小代码量.
第一个问题:对于这种情况,JSON反序列化在IE8上会运行得更快吗?
我们喜欢简单的RPC服务.我们有CustomRemoteService实现,CustomAsyncCallback实现,CustomRPCException实现等等.射频对我们来说是一个很大的变化.
第二个问题:使用返回单个JSON字符串然后反序列化客户端的RPC服务可以完成这项工作吗?
或者你能推荐另一种方法吗?
谢谢!
我需要从几个相似行的表中的一行中获取“td”元素内的“a”元素。问题是我只有“约翰”这个名字。如何在 XPath 中找到 john td -> 获取父级“tr” -> 然后获取“a”?
代码示例:
<?xml version="1.0" encoding="UTF-8"?>
<html>
<table>
...
<tr id='1'>
<td name='john'>
</td>
<td>
<a id='clickable'/>
</td>
<td>
</td>
</tr>
...
</table>
</html>
Run Code Online (Sandbox Code Playgroud)