我制作了这个控制器,用于发送电子邮件.我需要访问i18n
才能发送本地化的电子邮件.
class MailController {
MessageSource messageSource
static transactional = false
public void sendEmail() {
String name = "some name..."
String subject = message(code:"somemessagekey", args:[name])
// do some fancy stuff here...
}
}
Run Code Online (Sandbox Code Playgroud)
i18n
然后是文件(位于i18n
文件夹中):
file name: messages.properties
content: somemessagekey = Blabla {0} - blablabla
Run Code Online (Sandbox Code Playgroud)
运行之后,它会抛出(在集成测试中):
groovy.lang.MissingPropertyException:没有这样的属性:class的messageSource:org.codehaus.groovy.grails.support.MockApplicationContext
我没有想法如何处理控制器中的本地化(我也在服务中尝试过,但这更复杂).
我正在通过代码实现石英作业调度。下面是我安排和重新安排石英作业的方法。
void setJobSchedular(ScraperSearchOnRequest scraperSearchOnRequestInstance) {
try {
String groupName = "Scraper Group" + scraperSearchOnRequestInstance?.id
String jobName = "ScraperOnRequestJob"
Scheduler scheduler = getJobManagerService().quartzScheduler
JobKey jobKey = new JobKey(jobName, groupName);
//create JobDetail and Trigger
JobDetail jobDetail = JobBuilder.newJob(com.dogmasystems.scraper.ScraperOnRequestJob1.class).withIdentity(jobKey).build();
//add passing parameters to JobDataMap for first JobDetail
jobDetail.getJobDataMap().put("id", scraperSearchOnRequestInstance?.id?.toString());
jobDetail.getJobDataMap().put("groupName", groupName);
if (scheduler.checkExists(jobKey)) {
println("Rescheduling the old job having group name " + groupName)
Trigger oldTrigger = scheduler.getTrigger(new TriggerKey(jobName, groupName))
TriggerBuilder tb = oldTrigger.getTriggerBuilder();
Trigger newTrigger = tb.startAt(scraperSearchOnRequestInstance.scheduledTime).usingJobData("id",
scraperSearchOnRequestInstance?.id?.toString()).build()
scheduler.rescheduleJob(oldTrigger.key, newTrigger); …
Run Code Online (Sandbox Code Playgroud) 我知道这是一个非常基本的问题.但我很困惑.正确地说,我不知道为什么我们需要将String转换为CharArray.我知道toCharArray()
方法的工作.只有我想要一些实时的例子,说明为什么我们需要这种方法.
在我的问题中,我也想了解charArray与hashcode的关系.
我知道charArray代表:
char[] charArray ={ 'a', 'b', 'c', 'd', 'e' };
Run Code Online (Sandbox Code Playgroud)
例
public class Test {
public static void main(String args[]){
String a = "bharti";
char[] charArray = a.toCharArray();
System.out.println(charArray);
}
}
Run Code Online (Sandbox Code Playgroud)
输出:bharti
对我来说,输出和变量'a'中的字符串bharti 没有 区别 .
问题创建源:
实际上我想编写一个代码来生成哈希密码,所以我从谷歌那里读了一些代码,主要是在其中使用了CharArray()方法.所以我没有得到我们为什么使用这个.
我在Wildfly 14部署CAS 5.3.10,使用Maven的覆盖在指定https://apereo.github.io/cas/5.3.x/installation/Configuring-Servlet-Container.html#external和使用项目模板位于:https : //github.com/apereo/cas-overlay-template/tree/5.3
我已经编辑了可以在Wildfly 9上正确部署的pom,但是在Wildfly 14上部署失败,但有以下异常:
由以下原因引起的:java.lang.IllegalArgumentException:object不是在sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)处声明类的实例。在Sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)处org.springframework.core.io.VfsUtils.getFile(VfsUtils)上的java.lang.reflect.Method.invoke的未知源(org.springframework.core.io.VfsUtils.invokeVfsMethod(VfsUtils.java:100)处的Unknown Source) .java:172)位于org.springframework.core.io.VfsResource.getFile(VfsResource.java:90)位于org.apereo.cas.util.CasVersion.getDateTime(CasVersion.java:59)位于org.apereo.cas。 util.SystemUtils.getSystemInfo(SystemUtils.java:50)...........
问题似乎与CasVersion
尝试通过VFS(通过spring)访问以检索与模块的最后修改日期有关的信息的类有关。
我正在为我的Plone网站开发一个新的附加组件,因此它显示了我的错误
configure.zcml : unbound prefix.
Run Code Online (Sandbox Code Playgroud)
在这里,我正在编写我的zcml代码:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:five="http://namespaces.zope.org/five"
xmlns:i18n="http://namespaces.zope.org/i18n"
i18n_domain="customer.reports">
<five:registerPackage package="." initialize=".initialize" />
<include package="plone.resource" file="meta.zcml"/>
<plone:static
directory="templates"
type="reports"
name="customer"
/>
</configure>
Run Code Online (Sandbox Code Playgroud)
未绑定的前缀错误如下所述.
文件"/Plone/Python-2.7/lib/python2.7/xml/sax/handler.py",第38行,在fatalError引发异常zope.configuration.xmlconfig.ZopeXMLConfigurationError:文件"/ Plone/zinstance/parts/instance/etc/site.zcml",第16.2-16.23行ZopeXMLConfigurationError:文件"/Plone/buildout-cache/eggs/Products.CMFPlone-4.3-py2.7.egg/Products/CMFPlone/configure.zcml",第98.4-102.10行ZopeSAXParseException :文件"/Plone/zinstance/src/customer.reports/customer/reports/configure.zcml",第13.2行,未绑定前缀