Sometimes, we need override class LoginController or LogoutController when using ajax authentication function of Grails Spring Security plugin. But in 2.0RC version, after you run s2-quickstart, the LoginController and LogoutController class are not created in the grails-app\controllers folder as before. where're they now? Oh, they're hidden deeply:
\target\work\plugins\spring-security-core-2.0-RC2\grails-app\controllers\grails\plugin\springsecurity
if you still can not find it, please use file search function in the IDE.
Remember copying the file to grails-app\controllers folder before you using and override it.
2013-10-31
get error when use logout in the page genarated by Grails Spring Security Pluin
the error message is:
The specified HTTP method is not allowed for the requested resource.
reason:
Grails Spring Security Plugin use GET request to logout, but its config set default logout request methord to POST for safety reason.
solution:
in Config.groovy, add:
or, just use POST request to logout in your application, that's more safe.
The specified HTTP method is not allowed for the requested resource.
reason:
Grails Spring Security Plugin use GET request to logout, but its config set default logout request methord to POST for safety reason.
solution:
in Config.groovy, add:
grails.plugin.springsecurity.logout.postOnly = false
or, just use POST request to logout in your application, that's more safe.
@Secured annotation can not be resolved in Grails 2.3.1
error message in editor:
Secured is not an annotation in @Secured
solution:
add:
Secured is not an annotation in @Secured
solution:
add:
import grails.plugin.springsecurity.annotation.Secured
2013-10-30
How to install Spring Security Core Plugin 2.0 in Grails
1. in BuildConfig.groovy, add:
compile ':spring-security-core:2.0-RC2'and maven repository:
mavenRepo 'http://repo.spring.io/milestone'
note: if not set this maven repository, you will get error:
org.springframework.security#spring-security-core;3.2.0.RC1: not found
2. run
$ grails compilenote: if skip this step you will get error:
Error org.codehaus.groovy.grails.cli.ScriptNotFoundException
3. then run
$ grails s2-quickstart com.testapp User Role4. done.
Android程序通过http访问自己PC上的web应用程序,总是返回请求被拒绝
最近使用Android studio学习Android手机程序开发,并且采用第三方Android-Query库简化界面控件访问和http网络操作。我准备让我的Android程序访问我用Grails编写的很简单的web应用程序,并得到JSON数据。
访问Grails Web应用的URL为:http://localhost:8090/GrailsTest1/main/index, 在浏览器中访问这个URL可以得到正确的JSON结果, 但我启动Android Genymotion模拟器, 代码中用Android-Query的ajax方法访问始终返回“Network Error”,为更清楚地得到网络错误的具体原因,把AQuery的ajax访问改成Android的HttpClient异步网络调用,得到返回的错误为请求被对方拒绝。
在网上发帖咨询,有人说可能是CORS的原因,但我发现我的Android代码可以访问ip.jsontest.com并得到正确的JSON结果,如果是CORS的问题,在对客户端程序进行相应CORS的修改前,访问任何web应用都不应该得到结果的,因此排除是CORS问题。
继续在网上搜索并试验,最终发现了原因:Android模拟器会使用localhost表示自己的地址,而提供另一个特定的IP作为宿主主机地址给Android程序使用,经过测试,这个IP地址是10.0.3.2。我把Android程序中访问web应用的地址改成http://10.0.3.2:8090/GrailsTest1/main/index。奇迹出现了,看到了企盼已久的JSON返回结果。
访问Grails Web应用的URL为:http://localhost:8090/GrailsTest1/main/index, 在浏览器中访问这个URL可以得到正确的JSON结果, 但我启动Android Genymotion模拟器, 代码中用Android-Query的ajax方法访问始终返回“Network Error”,为更清楚地得到网络错误的具体原因,把AQuery的ajax访问改成Android的HttpClient异步网络调用,得到返回的错误为请求被对方拒绝。
在网上发帖咨询,有人说可能是CORS的原因,但我发现我的Android代码可以访问ip.jsontest.com并得到正确的JSON结果,如果是CORS的问题,在对客户端程序进行相应CORS的修改前,访问任何web应用都不应该得到结果的,因此排除是CORS问题。
继续在网上搜索并试验,最终发现了原因:Android模拟器会使用localhost表示自己的地址,而提供另一个特定的IP作为宿主主机地址给Android程序使用,经过测试,这个IP地址是10.0.3.2。我把Android程序中访问web应用的地址改成http://10.0.3.2:8090/GrailsTest1/main/index。奇迹出现了,看到了企盼已久的JSON返回结果。
2013-10-29
Failed to run new Grails project after upgrade to Grails2.3
after upgrade to Grails 2.3, when you create a new default Grails project, then run-app, it will failed and get error: :
- Groovy: compiler mismatch Project level is: 2.1 Workspace level is 2.0
- No such property: descriptor for class: org.codehaus.groovy.grails.plugins.GrailsPluginInfo
- No such property: version for class: org.codehaus.groovy.grails.plugins.GrailsPluginInfo
How to solve it? here is it:
- open Dashboard
- install Groovy 2.1 Eclipse Extension
- restart GGTS
- (might need clean your project after restart)
- open eclipse's Run - Run configuarations, then click "Run" button
2013-10-28
use Android-Query in Android Studio
1. in build.gradle, add:
dependencies { compile 'com.googlecode.android-query:android-query:0.24.3' }
2. in Fragment class:
public static class PlaceholderFragment extends Fragment { private AQuery aq; public PlaceholderFragment() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); aq = new AQuery(getActivity(), rootView); aq.id(R.id.button1).clicked(this, "onButtonClick"); return rootView; } public void onButtonClick(View view) { aq.id(R.id.editText).text("test text"); } }
Subscribe to:
Posts (Atom)