小编6to*_*ton的帖子

knockoutjs - ko.mapping.fromJS无效

我刚刚开始尝试knockout.js.ko.mapping提供了一种从服务器获取和映射数据的极好方法.但是我无法使映射工作.

我有一个简单的模型:

//var helloWorldModel;
var helloWorldModel = {
    name: ko.observable('Default Name'),
    message: ko.observable('Hello World Default')
};


$(document).ready(function() {
  ko.applyBindings(helloWorldModel);
      //a button on the form when clicked calls a server class 
      //to get json output
  $('#CallServerButton').click(getDataFromServer);
});

function getDataFromServer() {
  $.getJSON("HelloSpring/SayJsonHello/chicken.json", function(data) { 
    mapServerData(data);
  });
}

function mapServerData(serverData) {
  helloWorldModel = ko.mapping.fromJS(serverData, helloWorldModel);
  alert(JSON.stringify(serverData));
}
Run Code Online (Sandbox Code Playgroud)

helloWorldModel只有2个属性 - 与服务器返回的完全相同.mapServerData中的警报显示 -

{"name":"chicken","message":"JSON hello world"}
Run Code Online (Sandbox Code Playgroud)

我查找了有关类似问题的其他帖子,但似乎都没有解决这个问题.也许我错过了一些非常基本的东西 - 想知道是否有人可以指出它.

另请注意,如果我没有预先声明模型并使用

 helloWorldModel = ko.mapping.fromJS(serverData);
Run Code Online (Sandbox Code Playgroud)

它正确地将数据映射到我的表单.

javascript knockout-mapping-plugin knockout.js

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

在Java EE透视图的"新建"菜单中添加"类"选项

我几乎总是在eclipse中使用Java EE透视图.但是每次我需要添加一个类时我都要做New> Other> Class

有没有办法自定义透视图显示的新菜单,以便我在该菜单中有新的类选项(只需点击2次)

java eclipse

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

带弹簧的CGLIB抛出IllegalAccessError

我有一个Spring应用程序,启用了aop,使用cglib代理进行日志记录:

<?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:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<aop:aspectj-autoproxy proxy-target-class="true"/>

<bean id="loggingPointcuts" class="com.coverall.integration.commons.logging.LoggingPointcuts"/>

<bean id="loggingAspect" class="com.coverall.integration.commons.logging.LoggingAspect"/>
</beans>
Run Code Online (Sandbox Code Playgroud)

我使用cglib-nodep-2.2.2.jar和spring 3.1.1这在tomcat或jetty中运行良好.但是,当我在OC4J(使用jdk1.6)上部署它时,我收到以下错误:它试图代理的类 - ComponentRegistryImpl是包私有

Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.company.int.components.core.registration.ComponentRegistryImpl]: Common causes of this problem include using a final class or a non-visible class; nested exception is net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
    at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:207) ~[org.springframework.aop-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:112) ~[org.springframework.aop-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:476) ~[org.springframework.aop-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:362) ~[org.springframework.aop-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322) ~[org.springframework.aop-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1461) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE] …
Run Code Online (Sandbox Code Playgroud)

proxy weblogic oc4j spring-aop cglib

3
推荐指数
1
解决办法
6880
查看次数