私はjoda taglibを呼び出すクォーツジョブを持っていますが、他のものでも構いません。grailsはquartzジョブからtaglibを呼び出します
def joda = grailsApplication.mainContext.getBean('grails.plugin.jodatime.taglib.FormattingTagLib')
def formatDate = joda.format(value:event.startDate, style:"SS", locale:user.locale, zone:user.timeZone)
しかし、私はgettngています::
私はこのようにそれを行うことは、時間ではなくによってトリガーされるよう石英ジョブがバインド要求ではないので、絶対に理にかなって
org.quartz.JobExecutionException: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request. [See nested exception: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.]
要求。
私は周りを検索しましたが、解決策の解決策は見つかりませんでした。誰かが私にヒントを与えることができますか?
あなたの答えをありがとう。私はまた、DateTimeFormatterを使って解決策を思いついた。しかし、私はあなたの答えを受け入れることができません(良い)私の問題に解決策を与えたが、質問は私が石英の仕事の中でTagLibを呼び出すことができた方法でした – Bernhard
また、現在の要求を取得しようとしているjoda TagLib私はロケール属性を渡しているので、要求は使用されません)。すべてのTagLibに対する一般的な問題です。彼らはコードブロックに入っていません。もし私がTagLibメソッドの最初のところでlog.debugを実行した場合のイベント – Bernhard
そして私の答えは、あなたが単純にそうしていないということでした。私はそれが可能だと確信していますが、taglibが通常の状況下で動作していると思うようにリクエストを注入する必要があるため、歯を引っ張るようなものです。カスタムタグライブラリの場合、少なくともサービスのような別の場所に共通コードを置き、それをjobとtaglibから呼び出す方がよいでしょう。サードパーティのtaglibの場合、残念ながらコードの重複があります。もう一度、石英の仕事*からtaglibを呼び出す方法は、まったくそれをすることではありません。 –