Tag: grails

如何在Grails或Java Application中轻松实现“谁在线”?

我正在建立一个grails的社区网站(使用Apache Shiro进行安全和身份validation系统),我想实现“谁在线?”这一function。 这个urlhttp://cksource.com/forums/viewonline.php (如果您没有访问此url,请参阅下面的快照)给出了我想要实现的示例。 我怎么能以最简单的方式做到这一点? Grails或Java中是否存在任何现有解决方案? 谢谢。 快照: Who的快照在线页面http://sofzh.miximages.com/java/www.freeimagehosting.net或在此处查看: http : //www.freeimagehosting.net/image.php?2de8468a86.png

有效的Java代码是无效的Groovy代码?

大多数Java代码也是语法上有效的Groovy代码。 但是,有一些例外情况引起了我的疑问: Java中哪些构造/特性在语法上在Groovy中无效? 请提供非有效Groovy代码(Groovy 1.6)的Java代码(Java 1.6)的具体示例。 更新: 到目前为止,我们已经有五个语法有效的Java代码示例,它们不是有效的Groovy代码: 数组初始化 内课 def是Groovy中的关键字,但不是Java中的关键字 “$$” -strings – 在Groovy中解析为无效的GString 非静态初始化块– class Foo { Integer x; { x = 1; } } — class Foo { Integer x; { x = 1; } } 这是完整的清单吗? 还有其他例子吗? 更新#1:我已经开始提出这个问题了。 赏金将授予提供最全面的示例列表的人。 到目前为止,我们已经发现了五个例子,但我确信还有更多的例子。 所以让他们来吧!

使用JAX-RS的FileUpload

我尝试从JavaScript客户端上传文件到JAX-RS Java服务器。 我在我的服务器上使用以下REST上传function: @POST @Produces(‘application/json’) UploadDto upload( @Context HttpServletRequest request, @QueryParam(“cookie”) String cookie) { def contentType byte [] fileBytes log.debug “upload – cookie: “+cookie try{ if (request instanceof MultipartHttpServletRequest) { log.debug “request instanceof MultipartHttpServletRequest” MultipartHttpServletRequest myrequest = request CommonsMultipartFile file = (CommonsMultipartFile) myrequest.getFile(‘file’) fileBytes = file.bytes contentType = file.contentType log.debug “>>>>> upload size of the […]

关于空间/时间的Groovy集合性能考虑因素

与普通的Java for循环相比,Groovys集合方法(关于空间(!)和时间)的性能如何? 例如,对于这个用例: sum()vs for-loop with variable each()vs for-loop with variable inject()vs for-loop with variable 使用临时集合收集()与for循环 findAll()与for循环的临时集合 find()vs for-loop with variable 因此,考虑到这些结果,是否建议在关键环境中使用for循环而不是Groovy-collection-methods(例如Grails-WebApp)? 是否有关于Groovy / Grails性能(优化)的资源? 使用此GBench测试,我获得了以下CPU时间结果: user system cpu real forLoop 2578777 67 2578844 2629592 forEachLoop 2027941 47 2027988 2054320 groovySum 3946137 91 3946228 3958705 groovyEach 4703000 0 4703000 4703000 groovyInject 4280792 108 4280900 4352287 […]

没有节点的数据类型:org.hibernate.hql.internal.ast.tree.IdentNode HQL

我有HQL,我试图获得没有分类的工件(当活动为0时) artifacts = Artifact.findAll(“FROM Artifact WHERE id NOT IN ( SELECT artifact_id FROM Classification WHERE active = 1) AND document_id = :docid”,[docid:document.id], [max:limit, offset:startIndex]); 每当我跑,我得到错误 java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.IdentNode \-[IDENT] IdentNode: ‘artifact_id’ {originalText=artifact_id} 分类定义: class Classification { public static final String USER_DEFAULT = “USER” public static final String USER_SYSTEM = “SYSTEM” TaxonomyNode […]