# Daily **Repository Path**: libran/Daily ## Basic Information - **Project Name**: Daily - **Description**: 小小日报系统,只不过想学学grails - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2015-03-10 - **Last Updated**: 2020-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 过滤器 ---- 1. 同时排除一个controller里的多个action loginFilter(controller: 'account',action: '*',actionExclude:'(login|logout)'){} 自定义JSON、XML输出 ----- #### 方法一 在BootStrap的init中 def init = { servletContext -> JSON.registerObjectMarshaller( Activity ) { Activity activity -> return [ id : activity.id, content : activity.content, start : activity.start.format("yyyy-MM-dd HH:mm:ss"), end : activity.end.format("yyyy-MM-dd HH:mm:ss"), allDay:activity.allDay ] } } #### 方法二 使用Marshaller机制 Controller ---- #### 一个action对应多种格式的请求 //url : /controller/list?withFormat=html //GSP : /[domain]Controller/list.html.gsp def list() { //默认应该返回当月的 TODO def results = Activity.findAll() if (null == results) { render '' return } withFormat { html { return [activities: results] } 'json' { render results as JSON } } } 显示存在数据库里的图片 ---- def viewCurrentPersonsPortrait(){ response.setHeader("Content-disposition", "attachment; filename=1.jpg") response.contentType = 'image/jpeg' //'image/jpeg' will do too Account account = Account.findByName(session['accountName']) Person person = account.person byte[] bytes = account.person?.portrait response.outputStream << bytes //'myphoto.jpg' will do too response.outputStream.flush() } "/> TODO list ----- * 与他人合作完成一个活动 * 将活动打包发送给某人 * 允许别人查看自己的活动