我在Grails应用程序中有下一个Quartz作业.该工作计算一些统计数据,并发送和发送电子邮件与这些统计数据.我希望这份工作每天7点执行.
我的问题是每天工作三次而不是一次.
class DailyEmailJob {
def eventService
static triggers = {
cron name: 'emailTrigger', cronExpression: "0 0 7 * * ?"
}
def execute() {
eventService.send24StatsEmail()
}
}
Run Code Online (Sandbox Code Playgroud)
我在Apache Tomcat/7.0.35中托管Grails应用程序,运行Grails 2.2.1和quartz-1.0-RC6
我想使用Tomcat 6.0提供的标准资源工厂,它为我创建了javax.mail.Sessions实例.如JNDI Resource HOW-TO教程中所述.
我的META-INF/context.xml看起来像:
<?xml version="1.0" encoding="UTF-8"?>
<Context reloadable="true">
<Resource name="mail/Session"
auth="Container"
type="javax.mail.Session"
mail.smtp.host="smtp.gmail.com"
mail.smtp.port="587"
mail.smtp.auth="true"
mail.smtp.user="someone@gmail.com"
mail.smtp.password="secretpassword"
mail.smtp.starttls.enable="true"/>
</Context>
Run Code Online (Sandbox Code Playgroud)
我在WEB-INF/web.xml中有下一个resource-ref,就在</ webapps>之前.Web.xml验证.我使用McDowell的方式进行了验证.
<resource-ref>
<description>Resource reference to a factory for javax.mail.Session instances that may be used for sending electronic mail messages, preconfigured
to connect to the appropiate SMTP server.
</description>
<res-ref-name>mail/Session</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Run Code Online (Sandbox Code Playgroud)
我正在使用下一个代码snipett访问我的javax.mail.Session对象.
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
Session session = (Session)envCtx.lookup("mail/Session");
System.out.println("HERE smtp.user: " + session.getProperty("mail.smtp.user"));
Run Code Online (Sandbox Code Playgroud)
我在一个示例应用程序中测试它并且它工作 不幸的是,当我将相同的代码移动到struts应用程序时,我在上面的print语句中得到NULL.我在单例类中查找上下文,称为邮件程序(在我的WEB-INF/classes文件夹中定义)但如果我在Struts操作类中查找上下文,我会遇到同样的问题. …
我有一个JSON对象,其中包含一个名为callback的关键元素.
{
"id":34,
"description":"",
"item_id":4,
"callback":"addNew",
"filename":"0000072.doc",
"type":"News",
"ext":"doc",
"size":46592
}
Run Code Online (Sandbox Code Playgroud)
我想调用javascript"addNew"函数.我试过了.
json.callback(json);
Run Code Online (Sandbox Code Playgroud)
但是不起作用.任何的想法?
我添加了一个自定义验证方法来验证密码.但是,如果我得到的JSON是:
{"success":true}
Run Code Online (Sandbox Code Playgroud)
要么:
{"success":false}
Run Code Online (Sandbox Code Playgroud)
字段密码永远不会验证.
$(document).ready(function() {
// Ad custom validation
$.validator.addMethod('authenticate', function (value) {
$.getJSON("./json/authenticate.do",{ password: value},function(json) {
return (json.success == true) ? true : false;}
);
}, 'Wrong password');
$('form#changePasswordForm').validate({
rules: {
repeat_new_password: { equalTo: "#new_password" },
password : {authenticate: true}
}, submitHandler: function(form) {
$(form).ajaxSubmit( {
dataType: "json",
success: function(json) {
alert("foo");
}
});
}
});
});
Run Code Online (Sandbox Code Playgroud)
任何想法,我做错了什么?
我想构建一个应用程序,其中由电子邮件地址标识的用户可以拥有多个应用程序帐户.每个帐户可以包含一个或多个用户.我正在尝试将JDO存储功能与Google App Engine Java结合使用.这是我的尝试:
@PersistenceCapable
@Inheritance(strategy = InheritanceStrategy.NEW_TABLE)
public class AppAccount {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
private String companyName;
@Persistent
List<Invoices> invoices = new ArrayList<Invoices>();
@Persistent
List<AppUser> users = new ArrayList<AppUser>();
// Getter Setters and Other Fields
}
@PersistenceCapable
@EmbeddedOnly
public class AppUser {
@Persistent
private String username;
@Persistent
private String firstName;
@Persistent
private String lastName;
// Getter Setters and Other Fields
}
Run Code Online (Sandbox Code Playgroud)
当用户登录时,我想检查他所属的帐户数量.如果他或她属于多个人,那么他或她将被提供一个仪表板,他/她可以点击他/她想要加载的帐户.这是我的代码,用于检索他/她注册的应用帐户列表.
public static List<AppAccount> getUserAppAccounts(String username) {
PersistenceManager pm = JdoUtil.getPm();
Query q …Run Code Online (Sandbox Code Playgroud) 我想在几个页面之间共享我的HTML 头标记的内容,但是当我在HTML 头标记中使用require_once时,我遇到了一个奇怪的错误.让我解释一下.
如果我有下一个代码:
<!DOCTYPE html>
<html>
<head>
<title>Datos Soluciones Informáticas</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="/css/main.css">
</head>
Run Code Online (Sandbox Code Playgroud)
我检查代码,看起来像预期的那样.

但是,如果我将head标签的内容移动到外部文件/snippets/head.php
<meta charset="UTF-8">
<link rel="stylesheet" href="/css/main.css">
Run Code Online (Sandbox Code Playgroud)
然后在我的index.php文件中写下一个代码:
<!DOCTYPE html>
<html>
<head>
<title>Datos Soluciones Informáticas</title>
<?php require_once('/snippets/head.php'); ?>
</head>
Run Code Online (Sandbox Code Playgroud)
检查显示代码未插入适当的位置:

这不仅仅是检查不起作用的问题,而且页面的行为不符合预期.我有同样的问题与include替代require_once
使用view-source:localhost在chrome中获得的原始输出看起来不错,但页面渲染效果不佳
<!DOCTYPE html>
<html>
<head>
<title>Datos Soluciones Informáticas</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="/css/main.css">
</head>
<body>
Run Code Online (Sandbox Code Playgroud)
我在Windows 7机器中使用Xampp 6.1 Build 7601作为我的本地环境.
有谁知道我错过了什么?
我有一个Android应用程序,它使用actionbarsherlock和libs文件夹下的下一个jar:
android-support-v4.jar
gson-2.2.4.jar
libGoogleAnalyticsV2.jar
volley.jar
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用Android Studio Build#AI-130.692269生成签名APK.我检查两个复选框"运行ProGuard"和"包含系统proguard文件"
我的ProGuard路径文件proguard-project.txt如下所示:
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, …Run Code Online (Sandbox Code Playgroud) 我有一个网址,例如search.do?offset=20
偏移量有时在URL中,有时不在。当它不在URL中时,我希望它为0。
我尝试通过scriptlet检索值,但没有成功,如下所示:
<% Integer offset = (pageContext.findAttribute("offset")==null) ? new Integer("0") : new Integer((String) pageContext.findAttribute("offset")); %>
Run Code Online (Sandbox Code Playgroud)
有人知道我在做什么错吗?
我有一些代码:
import javax.activation.MimetypesFileTypeMap;
...
..
.
String filename = "foo.xls"; // Where this can be any file name .doc, .pdf or whatever
String headerContentType = new MimetypesFileTypeMap().getContentType(filename);
Run Code Online (Sandbox Code Playgroud)
似乎javax.activation.MimetypesFileTypeMap类里面rt.jar有JRE系统库(jdk1.6.0_10)但不是jdk1.5.0
我想避免使用1.6库.谁知道一个简单快捷的选择?
我有一些由Filemaker导出创建的html文件.每个文件基本上都是一个巨大的HTML表.我想遍历表行并将它们填充到数据库中.我试过用HTMLParser做如下:
String inputHTML = readFile("filemakerExport.htm","UTF-8");
Parser parser = new Parser();
parser.setInputHTML(inputHTML);
parser.setEncoding("UTF-8");
NodeList nl = parser.parse(null);
NodeList trs = nl.extractAllNodesThatMatch(new TagNameFilter("tr"),true);
for(int i=0;i<trs.size();i++) {
NodeList nodes = trs.elementAt(i).getChildren();
NodeList tds = nodes.extractAllNodesThatMatch(new TagNameFilter("td"),true);
// Do stuff with tds
}
Run Code Online (Sandbox Code Playgroud)
上面的代码适用于1 Mb以下的文件.不幸的是我有一个4.8 Mbs的html文件,我得到一个内存不足的错误.
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at org.htmlparser.lexer.Lexer.parseTag(Lexer.java:1002)
at org.htmlparser.lexer.Lexer.nextNode(Lexer.java:369)
at org.htmlparser.scanners.CompositeTagScanner.scan(CompositeTagScanner.java:111)
at org.htmlparser.util.IteratorImpl.nextNode(IteratorImpl.java:92)
at org.htmlparser.Parser.parse(Parser.java:701)
at Tools.main(Tools.java:33)
Run Code Online (Sandbox Code Playgroud)
有没有更有效的方法来解决HTMLParser的这个问题(我对图书馆来说是全新的),还是应该使用不同的库或方法?