小编Ami*_*tha的帖子

特殊字符 & 被打印为 &

在我的index.html.erb页面中,当从 MSSQL 查询数据时,它显示为 Me&Mine. 我试过这个:

$("#3").text("<%= escape_javascript(raw render(:partial => "var") %>");
Run Code Online (Sandbox Code Playgroud)

但它不起作用。

index.html.erb :

<%= link_to "Link", {:action => "AjaxView",:col => "colname"}, 
        :update => "Ajaxcall", :remote => true %>
<tr>
<td id="#3" style="height:25px">data displayed here</td>
Run Code Online (Sandbox Code Playgroud)

控制器:

def AjaxView
  @vars= Var.find(:all,:conditions => { :varName=> "one" },:select=>(params[:col]))
  respond_to do |format|
    format.js { render :layout=>false }
  end
end
Run Code Online (Sandbox Code Playgroud)

AjaxView.js.erb:

 if ( @col.to_s == "colName") {
   $("#3").text("<%= escape_javascript(render(:partial => "var") %>");
 }
 elsif ( @col.to_s == "colName1")
 {
   $("#2").text("<%= escape_javascript(render(:partial => …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1

3
推荐指数
1
解决办法
2667
查看次数

使用大括号 {} 的 MessageFormat

在Java中使用MessageFormat类在字符串中传递不同的变量时

System.out.println(MessageFormat.format("I want to resolve this statement "{  {0}, {1}  }", "this", "this"));  
Run Code Online (Sandbox Code Playgroud)

当您打印此内容时,它将显示 --> { {0}, {1} } 并且由于包裹在大括号中而不会解析带有值的参数。

java messageformat

3
推荐指数
1
解决办法
9979
查看次数