最近由于项目需要,用到了grails,这玩意确实好用,生产率高有类型python的速度与简洁。仅第一印象,用的还不深入,说的不对请轻拍。
遇到的几个问题:
1. groovy远程调试
玩Java的应该都知道在eclipse中有个java remote debug的功能,可以调试java拉起的程序,含jar,含web。
话说业界某公司做IDE,拖拽图元出来的代码,都能对图元进行远程调试,虽然那功能做的不是很漂亮,但也不错。
不多了,言归正传。
一个语言如果不能远程调试,那多痛苦啊,尤其是用在web后端的语言。因为一般上点规模的不是玩具的系统都会涉及到很多其他模块,在本机搭环境,会痛苦的一沓。何况很多系统的模块只支持Linux系统
找了好久未能解决。
stackoverflow有一哥们在问,但是也没具体结果
貌似结论就是不支持
How to debug Groovy code via the remote Java application debugging in Eclipse
后来,后来,终于在群里,—飞/aiq警 这个哥们告诉我上IntelliJ IDEA 这个IDE
我带着半信半疑的态度用了把,果然行。
再次谢谢 —飞/aiq警 这个哥们。
说下方法(我这边打出来war是放在tomcat容器中的)
1. 修改tomcat的启动脚本增加dtsocket配置已经打开远程debug的参数
2. 重启tomcat 确认8333端口已经监听
3. 配置IntelliJ, 与eclipse的远程调试类似,大同小异,只是菜单在地方不一样,快捷键不一样
我新建了一个远程debug配置
如下图1
然后启动这个debug 就可以连接到远程的server上了
然后run debug 刚才的那个远程debug就可以了
–
试下断点,果然行
2. 关于请求contriller中的action让其返回xml 出现404问题
在很多场景下,比如做api的需求,webservice的需求,都需要返回xml或者json格式的数据。
但是我按官网的文档区做,怎么做怎么就是404.
说我那个action对应的view不在,汗,我把那个view放上去,他就显示view中的内容,也不显示action中组装的xml的内容。
没招,试了很久,翻阅若干文档,国内的,国外的,E文不够好,看的不是很明白。
终于,终于,发现一个哥们说的,试了下,果然ok,
请猛戳这里REST Service XML Output in Grails via Content Negotiation
关键点在这里:
if you call http://localhost:8080/myapp/blah/list.xml or http://localhost:8080/myapp/blah/list?format=xml, you will get an XML result
其实,看到这里,这个问题,也不复杂。但是我为什么会被绕进去呢,嗯,(⊙_⊙),人品问题?好吧。
我解释下,这玩意按官网的说法,你要想响应回xml格式的内容,只需要
就可以了。
但是我的为什么出问题呢
原因是我测试的时候测试页面用的是post请求(当然我已经在urlMappings中配置上post对应的action
“/commonFileShare/preBatchDownload”(controller:”commonFileShare”) {
action = [POST:'preBatchDownload', GET:'preBatchDownload']
}
)
如果用get请求的话就是ok
后来我post的时候
http://192.168.1.148:8080/xxx/commonFileShare/preBatchDownload?format=xml
也是就说你用post方式请求的时候,后面加?format=xml
就可以啦。
–EOF–
相关推荐
Groovy和Grails配置方法 教你从0入手,一步一步深入安装和测试,包含环境和语言的下载地址
您可以在 Groovy轻松入门--搭建Groovy开发环境 学习到如何搭建Groovy环境,之后我会讲一下如何搭建Grails环境,然后手把手地写个Demo程序告终,我还会抽空写篇“Groovy轻松入门- -Grails实战之进阶篇” 一,搭建...
Grails参考手册 Grails学习资料 groovy 小白学习grails+groovy
eclipse插件grails(groovy)配置方法
Grails in Action Grails in Action Grails in Action Grails in Action Groovy in Action Grails in Action Grails in Action Groovy in Action Groovy in Action
Groovy_in_Action.pdf Groovy经典入门.pdf 使用Grails快速开发Web应用.pdf 在Eclipse里使用Grails类创建工具.pdf Programming Groovy. Dynamic Productivity for the Java Developer.pdf等一系列groovy资源
[Apress] Groovy, Grails, Griffon 入门教程 (英文版) [Apress] Beginning Groovy, Grails and Griffon (E-Book) ☆ 出版信息:☆ [作者信息] Vishal Layka, Christopher M. Judd, Joseph Faisal Nusairat, Jim ...
Grails Groovy 学习必备参考资料
Grails In Action.pdf ebook
Grails in Action pdf
Groovy and Grails Recipes.pdf ebook
begining groovy and grails
Grails In Action 2009最新版,英文的。很详细,学习groovy和grails的不二之选。
Groovy in Action is a comprehensive guide to Groovy programming, introducing Java developers to the new dynamic features that Groovy provides. To bring you Groovy in Action, Manning again went to the...
Groovy / Grails F2 The Best Web Server
Groovy / Grails F4 The Best Web Server
Groovy / Grails F3 The Best Web Server
groovy-grails-tool-suite-3.6.4.RELEASE-e4.4.2-win32-x86_64.part1 共两个压缩包,解压后将扩展名.zip.bak改为.zip再次解压。
Groovy轻松入门—Grails实战基础篇
介绍groovy语法和grails基本知识的ppt