我需要使用Youtube V3 API的Youtube相关视频的API URL.但我找不到直接的API调用,就像在版本2中一样.我错过了什么吗?
我有一个使用的Grails 2.0.0项目grails create-app.在我的HTML和GSP文件中,我试图包含jquery.js.我没有成功地尝试了以下所有方法:
<script type="text/javascript" src="jquery/jquery-1.7.1.js"></script>
<script type="text/javascript" src="jquery/jquery.js"></script>
<g:javascript library="jquery"/>
Run Code Online (Sandbox Code Playgroud)
前两个<script>标签导致404 Not Found(使用Firebug验证).的<g:javascript>在无标签结果被包括(认证使用视图源).
在我的Grails应用程序的主页上,它表明安装了jquery 1.7.1(在"INSTALLED PLUGINS"下).
Grails中包含jquery .js文件的正确方法是什么?
后续: .GSP文件:
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title>Test</title>
<g:javascript library="jquery/jquery"/>
</head>
<body>
<h1>Test</h1>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
以下HTML源代码中的结果:
<html>
<head>
<title>Test</title>
</head>
<body>
<h1>Test</h1>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
请注意,缺少jquery.js.
后续行动2:
我使用grails create-app以下方法创建我的应用:
13:56:40 ~/grailsDev $ grails create-app helloworld
| Created Grails Application at /Users/steve/grailsDev/helloworld
13:56:57 ~/grailsDev $ cd helloworld/
13:57:06 ~/grailsDev/helloworld $ ls -al …Run Code Online (Sandbox Code Playgroud) 我正在使用以下正则表达式验证URL.我也想验证google.com,但它返回false.可以在下面的RE中更改以验证google.com.
console.log(learnRegExp('http://www.google-com.123')); // false
console.log(learnRegExp('https://www.google-com.com')); // true
console.log(learnRegExp('http://google-com.com')); // true
console.log(learnRegExp('http://google.com')); //true
console.log(learnRegExp('google.com')); //false
function learnRegExp(){
return /^(ftp|https?):\/\/+(www\.)?[a-z0-9\-\.]{3,}\.[a-z]{3}$/.test(learnRegExp.arguments[0]);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试为MySQL和共享主机所需的资源设置理想的性能设置.
我的问题是,max_connections真正意味着什么?
它是对服务器进行的唯一并发请求的数量吗?因此,如果有两个用户,1个打开1个选项卡,另一个打开4个选项卡...并且同时按下所有选项卡重新加载,是否会有5个连接到MySQL数据库?因此,如果我们将这个场景推向:10个人有2个标签,31个人有一个标签,所有人同时按下刷新...我们max_connections在50岁时,每个人都会被锁定吗?
我问的原因是因为我max_connections一直认为该网站进入CPU限制模式,因此我想用低保护率来保存内存资源
谢谢您的帮助
在Grails中,有一个变体如何从源代码中包含本地插件.根据文档,可以输入BuildConfig.groovy:
// Useful to test plugins you are developing.
grails.plugin.location.shiro =
"/home/dilbert/dev/plugins/grails-shiro"
// Useful for modular applications where all plugins and
// applications are in the same directory.
grails.plugin.location.'grails-ui' = "../grails-grails-ui"
Run Code Online (Sandbox Code Playgroud)
问题是它在Grails 2.0.RC1中不起作用.我已经尝试过grails clean,安装插件grails install-plugin并将其放置BuildConfig.groovy.仍然无法解决.
我想让我的Grails应用程序只支持一种语言,我可以在某处定义,完全忽略客户端的标题或"lang"参数.我有什么方法可以这样做吗?谢谢.
我对基于JVM堆栈的WEB开发有点新手,但是未来的项目将需要一些基于JVM的WEB引擎.因此,我开始寻找一些可以快速制作的东西并转而尝试Grails.从书中看起来很不错,但真正长时间的启动时间给我留下了深刻印象(grails run-app)我决定在负载下测试它是如何工作的.这里是:
测试应用程序:按照这里的一些说明从地面开始(假设你已经安装了Grails和Tomcat,需要2分钟):
_http://grails.org/Quick+Start
测试用例(使用Apache基准测试 - 附带Apache httpd - _http://httpd.apache.org):
ab.exe -n 500 -c _http:// localhost:8080/my-project/book/create
(注意:这只是在样式容器中显示2个输入字段)
硬件:Intel i5 650(4Core*3.2GHz)8GB Ram&Win Server 2003 x64
结果是......
Grails:32 Req/Sec
Total transferred: 1380500 bytes
HTML transferred: 1297500 bytes
Requests per second: 32.45 [#/sec] (mean)
Time per request: 308.129 [ms] (mean)
Time per request: 30.813 [ms] (mean, across all concurrent requests)
Transfer rate: 87.51 [Kbytes/sec] received
Run Code Online (Sandbox Code Playgroud)
(只有32 Req/Sec,CPU饱和度为100%,这远低于我对这类硬件的预期)
...接下来 - 我试图比较它与类似的虚拟JSF应用程序(我在这里拿了一个:_http://www.ibm.com/developerworks/library/j-jsf2/ - 寻找"带有JAR文件的源代码",里面有\ jsf-example2\target\jsf-example2-1.0.war),
结果是......
JSF:400 Req/Sec …
我在Grails 2.0项目的一个服务中使用消息包来获取国际化文本.用例是一个通过邮件插件以异步方式发送的电子邮件主题,因此在控制器或TagLib中使用它是没有意义的(考虑到通常的参数是不访问服务中的文本或视图) ).这段代码在我运行的Grails应用程序中运行良好,但我不确定如何测试它.
我PluginAwareResourceBundleMessageSource在我的defineBeans中尝试过,因为这是我正在运行的应用程序注入的内容,但它导致了nullpointers,因为它似乎需要围绕插件管理器进行一系列设置,这样我的测试环境就不会给予(甚至集成).
然后我尝试了一个ReloadableResourceBundleMessageSource纯粹的Spring,但它似乎无法看到我的.properties文件,并且在代码'my.email.subject'下找到了没有消息的locale'en'失败.
我觉得我有点陷入虫洞,因为在服务中访问Grails i18n没有记录在grails文档中,所以如果有一个首选的方法,请告诉我.
请注意我的.properties文件位于标准grails-app/i18n位置.
考试
@TestFor(EmailHelperService)
class EmailHelperServiceTests {
void testSubjectsDefaultLocale() {
defineBeans {
//messageSource(PluginAwareResourceBundleMessageSource); Leads to nullpointers
messageSource(ReloadableResourceBundleMessageSource);
}
String expected = "My Expected subject Passed1 Passed2";
String actual = service.getEmailSubjectForStandardMustGiveGiftFromBusiness(Locale.ENGLISH, Passed1 Passed2);
assertEquals("email subject", expected, actual);
}
Run Code Online (Sandbox Code Playgroud)
服务:
class EmailHelperService {
def messageSource;
public String getEmailSubject(Locale locale, String param1, String param2) {
Object[] params = [param1, param2].toArray();
return messageSource.getMessage("my.email.subject", params, locale );
}
Run Code Online (Sandbox Code Playgroud) 我一直在从Grails 2.0的Grails 1.3.7迁移中解决各种资源包含问题,可能还不了解一些事情.
首先,做什么
<g:javascript library="application" />
Run Code Online (Sandbox Code Playgroud)
做?(这是在Grails 1.3.7中提供的默认main.gsp中).
其次,为了在我的应用程序中包含jquery,我可以这么做
<r:require module='jquery' />
<r:layoutResources />
Run Code Online (Sandbox Code Playgroud)
在我的主sitemesh页面的顶部
<g:layoutHead />
...
<g:layoutBody />
Run Code Online (Sandbox Code Playgroud)
和"完成它",使用
<r:layoutResources />
Run Code Online (Sandbox Code Playgroud)
之后的第二次
<g:layoutBody />
Run Code Online (Sandbox Code Playgroud)
谢谢
我有这样的用户类:
class User {
transient springSecurityService
String displayName
String password
<snip>
protected void encodePassword() {
password = springSecurityService.encodePassword(password)
}
}
Run Code Online (Sandbox Code Playgroud)
还有一个UserController.我正在尝试编写单元测试UserController但是我收到此错误用于保存,更新和删除测试:
java.lang.NullPointerException: Cannot invoke method encodePassword() on null object
Run Code Online (Sandbox Code Playgroud)
我有什么方法可以通过嘲讽来实现这一点?
我已经尝试了许多模拟代码的组合,如下所示,但我不知所措.
defineBeans {
springSecurityService(SpringSecurityService)
}
Run Code Online (Sandbox Code Playgroud)
任何建议将不胜感激.
grails ×7
grails-2.0 ×5
drupal ×1
groovy ×1
html ×1
javascript ×1
jquery ×1
mocking ×1
mysql ×1
performance ×1
regex ×1
service ×1
testing ×1
unit-testing ×1
validation ×1
youtube-api ×1