我必须从控制器中检索Map
并将详细信息显示为JSP上的表。从控制器返回的地图是Map <String, List>.
我该怎么做?
答案 0 :(得分:5)
这就像在java中一样简单。
我建议您安装JSTL jar文件并在文件中使用taglibs。然后使用require "open3"
cmd="curl -b cookie.txt #{url} -L -o -"
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
pid = wait_thr.pid
# I have to process stdout and stderr at the same time but
#asyncronously, because stdout gives much more data then the stderr
#stream. I instantiate a Thread object for reading the stderr, otherwise
#"getc" would block the stdout processing loop.
c=nil
line=""
stdout.each_char do |b|
STDOUT.print b
if c==nil then
c=""
thr = Thread.new {
c=stderr.getc
if c=="\r" || c=="\n" then
STDERR.puts line
line=""
else
line<<c
end
c=nil
}
end
#if stderr still holds some output then I process it:
line=""
stderr.each_char do |c|
if c=="\r" || c=="\n" then
STDERR.puts line
line=""
else
line<<c
end
end
exit_status = wait_thr.value.exitstatus
STDERR.puts exit_status
end #popen3
标记迭代地图并打印它们。
在你的情况下,
<c: forEach>