首页 \ 问答 \ BeanUtils.copyproperties日期属性复制问题?(BeanUtils.copyproperties Date property copying issue?)

BeanUtils.copyproperties日期属性复制问题?(BeanUtils.copyproperties Date property copying issue?)

我使用commons-beanutils 1.8.3和Date属性作为java.util.Date。

当我尝试将Source复制到目标时,它无法复制日期属性。

以下显示了我之前的问题,但没有人给我正确答案。

作为一个例子,我在源bean中的日期值是Wed May 15 15:46:04 IST 2013,但是BeanUtils无法将其复制到目标...

BeanUtills日期转换问题


I am using commons-beanutils 1.8.3 and and Date properties as java.util.Date.

When i am trying to copy Source to destination it's unable to copy date properties.

Following shows my previous issue but no one give the correct answer for me.

as a example my date value in source bean is Wed May 15 15:46:04 IST 2013, but BeanUtils unable to copy this to destination...

BeanUtills Date conversion Issue


原文:https://stackoverflow.com/questions/16579518
更新时间:2023-06-25 22:06

最满意答案

您应该能够渲染js并使用create.js.erb

请尝试:

# MailsController
def create
    @mail = Mail.new(mail_params)

    if @mail.save
      respond_to do |format| 
        format.js
      end
    else
      render :new
    end
END

然后,在app/views/mails/create.js.erb实现您的javascript。


You should be able to render js and use create.js.erb.

Please try:

# MailsController
def create
    @mail = Mail.new(mail_params)

    if @mail.save
      respond_to do |format| 
        format.js
      end
    else
      render :new
    end
END

Then, implement your javascript in app/views/mails/create.js.erb.

相关问答

更多
  • <%= broadcast "/forums/new" do %> 正在吐出执行的结果为javascript(即HTTOK),这使得它变得简单。 所以它应该是 <% broadcast "/forums/new" do %> 注意缺少=。 <%= broadcast "/forums/new" do %> is spitting the result of the execution as javascript (that HTTOK) which makes it go meh. So it sho ...
  • 我通过在jQuery脚本中添加addingClass到元素来解决此问题,然后在js.erb使用if statement来检查该类。 如果有更好的方法,请让我知道。 I solved this by addingClass to the element in the jquery script and then using an if statement in the js.erb to check for that class. If there is a better way, please let me ...
  • 您应该能够渲染js并使用create.js.erb 。 请尝试: # MailsController def create @mail = Mail.new(mail_params) if @mail.save respond_to do |format| format.js end else render :new end END 然后,在app/views/mails/create.js.erb实现您的javasc ...
  • JavaScripts不在控制器操作的上下文中编译,因此您不能使用在控制器中分配的实例变量。 您可能有两种选择: 从chart.js文件中通过AJAX从服务器加载数据 在页面呈现期间将@book数据存储到DOM中,例如。 作为JSON ,然后从chart.js读取它 第二个选项更容易解释: 使用购物车将相应的代码添加到您的页面: