在Spring安全版3.0.6中修复了CRLF注销漏洞(https://jira.springsource.org/browse/SEC-1790),他们禁用了'spring-security-redirect'参数.
3.0.6中也删除了对注销URL中的重定向参数的默认支持.在3.1中,它已经需要明确启用.
有没有办法重新打开重定向参数,以便我可以在我的Grails Spring Security Logout Controller中动态重定向?
LogoutContoller.groovy
def user = springSecurityService.currentUser
if (params.redirect) {
// this needs to log the user out and then redirect, so don't redirect until we log the user out here
log.info "Redirecting " + springSecurityService.currentUser.username + " to " + params.redirect
// the successHandler.targetUrlParameter is spring-security-redirect, which should redirect after successfully logging the user out
redirect uri: SpringSecurityUtils.securityConfig.logout.filterProcessesUrl + "?spring-security-redirect="+params.redirect
return;
}
redirect uri: SpringSecurityUtils.securityConfig.logout.filterProcessesUrl // '/j_spring_security_logout'
Run Code Online (Sandbox Code Playgroud)
以下内容不再适用于spring security 3.0.6+的版本
我有一个Grails应用程序,其中一些页面只能通过https访问,一些页面可通过http访问.使用之前的过滤器可以轻松处理.然而HTTPS页面上时,只要一个控制器并重定向用户返回HTTP的结束,并通过过滤器再次指向HTTPS.
def update = {
...
redirect(action: "show", id: domainInstance.id)
}
Run Code Online (Sandbox Code Playgroud)
在Firebug我得到:
POST ... localhost:8443 (the form submit to controller)
GET ... 302 ... localhost:8080 (the redirect to show in controller)
GET ... 301 ... localhost:8443 (the redirect back to https in filter)
Run Code Online (Sandbox Code Playgroud)
如何让控制器重定向呼叫"记住"当前协议等?或者我做错了什么?
自从我开始评估Grails 2.0.0.RC3以来,最近出现了这个错误.我对控制器进行了简单的更改,然后保存.
从pictureList.count()某种程度上在1.3.7中起作用但在2.0.0RC3中起作用
def tagged = {
def pictureList = Picture.findAllByTag(params.id)
render(view: 'list', model: [pictureInstanceList:pictureList,
tag:params.id, pictureInstanceTotal:pictureList.count()])
}
Run Code Online (Sandbox Code Playgroud)
为了pictureList.size()使更多的意义,因为pictureList的类型是ArrayList
def tagged = {
def pictureList = Picture.findAllByTag(params.id)
render(view: 'list', model: [pictureInstanceList:pictureList,
tag:params.id, pictureInstanceTotal:pictureList.size()])
}
Run Code Online (Sandbox Code Playgroud)
我收到编译输出消息让我知道发生了什么.
| Compiling 1 source files
| Compiling 1 source files.
| Compiling 1 source files..
| Compiling 1 source files...
Run Code Online (Sandbox Code Playgroud)
然后我重新加载页面,我得到了这个.
| Error 2011-12-11 17:00:01,908 [Thread-7] ERROR plugins.AbstractGrailsPluginManager
- Plugin [controllers:2.0.0.RC3] could not reload changes to file
[/Users/gotomanners/Documents/Projects/sampleProject/grails-app/controllers/sampleProject/PictureController.groovy]:
java.lang.NoSuchFieldException: __timeStamp__239_neverHappen1323622798918
Message: …Run Code Online (Sandbox Code Playgroud) Grails中是否有一种简单的方法可以不允许删除任何域类?而是在每个域中都有一个删除标志,只要删除了某些内容就会更新.
此外,实际上所有list/show方法都不应显示delete flag为true的对象.
我知道我可以通过手动编辑所有控制器中的所有CRUD方法来做到这一点但是在使用Grails时似乎有点太多工作,其中一切都可以通过在某处更改一些标志来完成!
我的常用列表方法如下所示,我项目中的几乎所有列表方法都允许用户访问仅属于用户公司的内容.
def list = {
params.max = Math.min(params.max ? params.int('max') : 10, 100)
def documentsList = Documents.createCriteria().list(params){
eq("company.id",session.companyId)
maxResults(params.max)
order("dateCreated","desc")
//firstResult(params.offset)
}
[documentsInstanceList: documentsList , documentsInstanceTotal: documentsList.getTotalCount() ]
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用eclipse-jee-juno创建一个grails 2.2.0项目.它给了我一个错误
项目预期的Groovy编译器级别与工作区编译器级别不匹配.项目编译器级别为:1.8.X Workspace编译器级别为1.7.X转到项目属性 - > Groovy编译器为此项目设置Groovy编译器级别.
背景:我已经安装了grails 2.2.0并且我能够使用命令行(而不是eclipse)创建和运行示例项目/控制器
是否有一种简单的方法可以将JSON字符串反序列化为域类,并支持嵌入式关联; belongsTo和hasMany
{
name: "Customer",
contact: {
name: "Contact"
}
}
class Customer {
name
Contact contact
}
class Contact {
String name
static belongsTo = [customer:Customer]
}
Run Code Online (Sandbox Code Playgroud)
在我的控制器中我想做以下事情
def save() {
def customer = new Customer(request.JSON)
customer.save();
}
Run Code Online (Sandbox Code Playgroud)
现在我被迫做了
def save() {
def contact = new Contact(request.JSON.contact);
def customer = new Customer(request.JSON);
customer.contact = contact;
customer.save();
}
Run Code Online (Sandbox Code Playgroud) 运行Grails应用程序时出错.
我的应用程序在Grails 2.1.4中工作.
我在用
Groovy 2.1.*
Java 1.7
Tomcat 7.0.37
Run Code Online (Sandbox Code Playgroud)
我将我的应用程序从Grails 2.1.4升级到2.3.0.M1.我收到这样的错误之后:
| Loading Grails 2.3.0.M1
| Configuring classpath
| Error SLF4J: Class path contains multiple SLF4J bindings.
| Error SLF4J: Found binding in [jar:file:/home/testuser/.m2/repository/org/grails/grails-plugin-log4j/2.3.0.M1/grails-plugin-log4j-2.3.0.M1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
| Error SLF4J: Found binding in [jar:file:/home/testuser/.m2/repository/org/slf4j/slf4j-log4j12/1.6.6/slf4j-log4j12-1.6.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
| Error SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
| Error SLF4J: Actual binding is of type [org.slf4j.impl.GrailsSlf4jLoggerFactory]
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Compiling 143 source files.
Copying properties file...
| …Run Code Online (Sandbox Code Playgroud) 通常在Spring Source Tool Suite IDE或Eclipse Maven项目中,如果我想看看框架/库方法在幕后做什么,我可以按住Ctrl键并单击方法名称,它将带我到源代码.我知道很多Grails方法是在运行时动态添加的,因此IDE并不总是能够知道如何获取它们.否则,我可以在Google,Github或API文档中搜索该类.使用Grails核心源来更好地理解框架的最佳方法是什么?
例如,我想看看控制器中的响应方法是什么样的,以及当索引方法如下所示时,它如何将一个名为"clubInstanceList"的参数返回到我的club/index gsp:
def index(Integer max) {
params.max = Math.min(max ?: 10, 100)
respond clubService.list(params), model:[clubInstanceCount: clubService.count()]
}
Run Code Online (Sandbox Code Playgroud)
ctrl + click在IDE中不起作用,因为此方法是在运行时添加的.我在github上搜索了Grails核心源代码,但是不知道控制器上这种响应方法的包结构.
LinkedIn上的人们一直在以有趣的方式使用Play来处理需要由许多不同组件组成的页面:http://engineering.linkedin.com/play/composable-and-streamable-play-apps
他们如何做到的关键组成部分是Play中的"动作"返回完整的响应,因此能够通过更高级别的动作"组合"成另一个响应.
Grails似乎并没有真正从动作中返回任何东西(或者至少没有任何特定的东西),并且当你在一个动作中时,没有一种简单的方法可以调用另一个动作.
那么,Grails可以采用这种构图方式吗?
我为Grails app实现了不常用的架构,因为我制作了前控制器,它只能进一步转发请求(基于某些标准).我还将locale解析器实现为http servlet请求过滤器.事实证明,转发的请求再次通过过滤器链传递.所以流程看起来像这样:
在写这篇文章的同时,我提出了如何省略问题(我的具体实现).但我仍然很好奇它为什么会发生?前进应该在幕后工作.Java EE规范没有说明这种行为(转发javadoc).
grails ×10
grails-2.0 ×3
composition ×1
eclipse ×1
grails-2.3 ×1
grails-orm ×1
groovy ×1
httpresponse ×1
java ×1
servlets ×1