GWT多个html页面和导航

嗨首先我想提一下,我知道基于ajax的应用程序和重用相同的页面。 这里的要求是,我希望有两个单独的页面,一个用于登录,另一个用于主应用程序。 现在,这不是因为我只是想要它,而是因为我在两个页面中有非常不同的布局,我很乐意将html元素和css直接放在页面中,然后将div包含在动态html中以供gwt填充。 即使在myfaces的情况下,我还没有看到用于登录和主应用页面的相同页面的应用程序。 无论如何,我面临的问题是,让我说我有两页 Login.html with div:div id =“login” 带有div的main.html:div id =“main” 我已经在web.xml中的欢迎文件列表中声明了它们现在我从登录页面开始用gwt小部件填充“登录”div并点击按钮我使用以下jsni代码重定向到“/Main.html ?gwt.codesvr = 127.0.0.1:9997″ private native void gotoURL(String url)/ – {$ wnd.location.href = url; } – /; 然后尝试填充“主”div。 但我注意到的行为是应用程序再次调用入口点,它没有找到任何元素作为“登录”并给出NPE。 有没有办法做到这一点? 还要摆脱“?gwt.codesvr = 127.0.0.1:9997”? 谢谢

为什么我们不能使用构造函数本身初始化servlet?

为什么我们必须覆盖Servlet中的init()方法,同时我们可以在构造函数中进行初始化并让web容器调用构造函数,同时调用构造函数将ServletConfig引用传递给servlet? Ofcourse容器必须使用reflection,但容器必须使用reflection来调用简单的无参数构造函数

Maven Jetty插件中的Jetty JNDI错误

我正在尝试配置可以从Maven Jetty插件的调用中使用的JNDI数据源。 我试图在WAR文件外部执行此操作,以便稍后可能使用Jetty部署我们的webapp的任何人都不必编辑WAR的WEB-INF目录中的配置文件。 我创建了一个jetty.xml文件,如下所示: jdbc/myDataSource ……. 然后我在Maven插件中引用了这个文件,如下所示: org.mortbay.jetty maven-jetty-plugin config/jetty.xml 但是,当我尝试通过mvn jetty运行webapp时:run-war我收到以下错误: Embedded error: Object is not of type class org.mortbay.jetty.webapp.WebAppContext 如果我省略顶级元素并尝试直接通过以下方式创建新的JNDI资源: 然后我得到一个类似的错误: Embedded error: Object is not of type class org.mortbay.jetty.plus.naming.Resource 是什么赋予了?

SpringAOP与AspectJ的介绍

我是SpringAOP的新手。 我想写一些简单的介绍示例,但无法清楚地了解它必须如何工作。 在文档中我发现: 简介:代表类型声明其他方法或字段。 Spring AOP允许您向任何建议的对象引入新接口(和相应的实现)。 例如,您可以使用简介使bean实现IsModified接口,以简化缓存。 (引言在AspectJ社区中称为类型间声明。) 我写了一个简单的例子:我用一个方法编写简单的类 public class Test { public void test1(){ System.out.println(“Test1”); } } 然后我编写实现此接口的接口和类 public interface ITest2 { void test2(); } public class Test2Impl implements ITest2{ @Override public void test2() { System.out.println(“Test2”); } } 最后我的方面 @Aspect public class AspectClass { @DeclareParents( value = “by.bulgak.test.Test+”, defaultImpl = Test2Impl.class ) public […]

什么可能导致“IO错误java.net.SocketException:select failed”?

我的笔记本电脑上运行的服务器程序,相同的路由器和相同的代码。 它工作正常,客户可以连接。 然而,当我将工作区复制到我的PC并运行它时,我得到了这个废话: IO错误java.net.SocketException:选择失败 这是代码…… public static void main(String[] args) { System.out.println(“running server!”); int nreq = 1; try{ ServerSocket sock = new ServerSocket(7331); for(;;){ Socket newsock = sock.accept(); System.out.println(“Creating thread…”); //Thread t = new ThreadHandler(newsock, nreq); //t.start(); nreq++; } } catch(Exception e) { System.out.println(“IO error ” + e); } 基本上什么可能导致这个错误(我在网上找不到有用的信息)在一台PC而不是另一台PC上发生? 它必须与PC本身有关。 我最困惑。 基本上它无法打开套接字? 这是完整的堆栈跟踪: java.net.SocketException: […]

java.lang.IllegalArgumentException:找不到命名查询。(实体管理器未创建NamedQuery)

我正在使用hibernate 4.1.5.Final和Spring 3.1.2 Release以及Jboss 7.1。 我已经使用@NamedQuery注释在类中编写了所有命名查询,但实体管理器没有创建命名查询。 我发布了stacktrace和context.xml 09:58:49,695 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) java.lang.IllegalArgumentException: Named query not found: validateLoginHash 09:58:49,770 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) at org.hibernate.ejb.AbstractEntityManagerImpl.createNamedQuery(AbstractEntityManagerImpl.java:642) 09:58:49,772 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source) 09:58:49,774 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 09:58:49,777 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) at java.lang.reflect.Method.invoke(Method.java:597) 09:58:49,779 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365) 09:58:49,782 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) at $Proxy30.createNamedQuery(Unknown Source) […]

以编程方式实现以各种指定方式组合同一接口的某些实例的接口

实现以各种指定方式组合同一接口的某些实例的接口的最佳方法是什么? 我需要为多个接口执行此操作,并且我希望最小化样板并仍然实现良好的效率,因为我需要将其用于关键生产系统。 这是问题的草图。 抽象地说,我有一个通用的组合器类,它接受实例并指定各种组合器: class Combiner { I[] instances; T combineSomeWay(InstanceMethod method) { // … method.call(instances[i]) … combined in some way … } // more combinators } 现在,假设我想在许多其他界面中实现以下界面: Interface Foo { String bar(int baz); } 我想最终得到这样的代码: class FooCombiner implements Foo { Combiner combiner; @Override public String bar(final int baz) { return combiner.combineSomeWay(new InstanceMethod { @Override […]

使用MockServletContext进行unit testing

我已经使用Gradle设置了spring boot应用程序。 现在我明白了@EnableAutoConnfiguration根据类路径中的依赖关系来配置应用程序。 我很高兴避免所有的管道,但事情开始发生,我希望不会。 这是我的依赖项: dependencies { compile(‘org.springframework.boot:spring-boot-starter-web:1.2.3.RELEASE’) compile ‘org.springframework.hateoas:spring-hateoas:0.17.0.RELEASE’ compile ‘org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE’ compile ‘org.springframework.boot:spring-boot-starter-data-jpa’ compile ‘com.google.guava:guava:18.0’ compile ‘com.fasterxml.jackson.datatype:jackson-datatype-jsr310’ compile ‘commons-beanutils:commons-beanutils:1.9.2’ runtime ‘org.hsqldb:hsqldb:2.3.2’ testCompile ‘org.springframework.boot:spring-boot-starter-test’ testCompile ‘com.jayway.jsonpath:json-path:2.0.0’ } 我的应用类: @ComponentScan(“org.home.project”) @SpringBootApplication //@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL) public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } UserController的一个片段: @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) public […]

Google Calendar API和OAuth问题

我收到了错误 com.google.gdata.util.AuthenticationException: Unknown authorization header at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:600) ~[gdata-core-1.0.jar:na] at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563) ~[gdata-core-1.0.jar:na] at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552) ~[gdata-core-1.0.jar:na] at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530) ~[gdata-core-1.0.jar:na] at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535) ~[gdata-core-1.0.jar:na] 尝试通过API访问Google日历数据时。 以下是该错误之前发生的事情。 1)我通过Googlevalidation: final AccessTokenResponse response = new GoogleAuthorizationCodeGrant(httpTransport, jsonFactory, clientId, clientSecret, authorizationCode, redirectUrl).execute(); final GoogleAccessProtectedResource accessProtectedResource = new GoogleAccessProtectedResource( response.accessToken, httpTransport, jsonFactory, clientId, clientSecret, response.refreshToken); LOGGER.debug(“response.accessToken: {}”, response.accessToken); this.oauthAccessToken = response.accessToken; … 2)我通过任务API读取了一些数据: this.service […]

@Startup @Singleton在WebLogic中实例化两次(EJB 3.1)

我有一个标记为@Startup和@Singleton的类,构造函数被调用两次。 为什么被叫两次? WebLogic 12.1.1 本地运行(不是群集) 当@PostConstruct存在时,它也被调用两次 与XML配置无关(weblogic-ejb-jar.xml等) 这是class级: import java.util.concurrent.atomic.AtomicInteger; import javax.ejb.Singleton; import javax.ejb.Startup; @Startup @Singleton public class CacheStartupListener { static AtomicInteger count= new AtomicInteger(0); public CacheStartupListener() { System.err.println(“Singleton invoked ” + count.incrementAndGet() + ” ” + getClass().getClassLoader().toString()); } } 我可以从输出中看到构造函数都是从同一个类加载器中调用的。 构造函数中的wlfullclient-12.1.1jar都通过wlfullclient-12.1.1jar ,但wlfullclient-12.1.1jar 在其他方面是不同的。 这是第一个实例化的堆栈跟踪: Daemon Thread [[ACTIVE] ExecuteThread: ‘0’ for queue: ‘weblogic.kernel.Default (self-tuning)’] (Suspended […]