SSH中ognl取ation传过来的值 求大牛指导
SSH中ognl取ation传过来的值 求大牛指点
SSH中action里定义一个字符串str
接着str赋值一个表格的字符串,
然后str放到request去, jsp页面用ognl取值
取出来的是结果是放进去的表格字符串。
问题是:怎么样才能把那些字符串变成表格(网页源代码中str的"<"和">" 会被翻译成"<"和">",jsp页面正常显示"<"和">" 。试过用el表达式取str值在jsp页面显示是一个表格)
试用过放在LIst对象中 用迭代器取值还是不行,
使用过 str=str.replace("&", "&").replace("<", "<").replace(">", ">");还是不行。求大牛指点
SSH中action里定义一个字符串str
接着str赋值一个表格的字符串,
然后str放到request去, jsp页面用ognl取值
取出来的是结果是放进去的表格字符串。
问题是:怎么样才能把那些字符串变成表格(网页源代码中str的"<"和">" 会被翻译成"<"和">",jsp页面正常显示"<"和">" 。试过用el表达式取str值在jsp页面显示是一个表格)
试用过放在LIst对象中 用迭代器取值还是不行,
使用过 str=str.replace("&", "&").replace("<", "<").replace(">", ">");还是不行。求大牛指点
1 楼
iffanv
2012-02-28
补充
action 代码:
StringBuffer str=new StringBuffer();
str.append("<table width='200' border='1'><tr><th scope='row'> " +
"</th><td> </td></tr><tr><th scope='row'> " +
"</th><td> </td></tr></table> ");
/*String str1=str.toString();
str1=str1.replace("&", "&").replace("<", "<").replace(">", ">");
System.out.println(str1);*/
List<String> list=new ArrayList<String>();
list.add(str.toString());
System.out.println("list="+list);
request.setAttribute("list", list);
//request.setAttribute("str1", str1);
request.setAttribute("str", str.toString());
return "list";
jsp页面直接显示str是
<table width='200' border='1'><tr><th scope='row'> </th><td> </td></tr><tr><th scope='row'> </th><td> </td></tr></table>
查看html源文件的str
</head>
<body>
<br>
<table width='200' border='1'><tr><th scope='row'>&nbsp;</th><td>&nbsp;</td></tr><tr><th scope='row'>&nbsp;</th><td>&nbsp;</td></tr></table>
<table id="testTable" width="100%" border="1" class="t1">
另建工程用el 表示式取值则是个表格 ,截图不知道怎么上传先这样
action 代码:
StringBuffer str=new StringBuffer();
str.append("<table width='200' border='1'><tr><th scope='row'> " +
"</th><td> </td></tr><tr><th scope='row'> " +
"</th><td> </td></tr></table> ");
/*String str1=str.toString();
str1=str1.replace("&", "&").replace("<", "<").replace(">", ">");
System.out.println(str1);*/
List<String> list=new ArrayList<String>();
list.add(str.toString());
System.out.println("list="+list);
request.setAttribute("list", list);
//request.setAttribute("str1", str1);
request.setAttribute("str", str.toString());
return "list";
jsp页面直接显示str是
<table width='200' border='1'><tr><th scope='row'> </th><td> </td></tr><tr><th scope='row'> </th><td> </td></tr></table>
查看html源文件的str
</head>
<body>
<br>
<table width='200' border='1'><tr><th scope='row'>&nbsp;</th><td>&nbsp;</td></tr><tr><th scope='row'>&nbsp;</th><td>&nbsp;</td></tr></table>
<table id="testTable" width="100%" border="1" class="t1">
另建工程用el 表示式取值则是个表格 ,截图不知道怎么上传先这样