如何实现这样的页面传值带参效果
本帖最后由 qwe065560 于 2013-12-25 18:37:19 编辑
如何实现下列伪代码实现的效果
简单说就是在action中调用一个赋值方法,然后在页面用EL表达式取出这个方法中的值
private void aaa(
string a="1.html";
string b="2.html";
string c="3.html";
string d="4.html";
}
public ActionForward toPage(ActionMapping mapping,ActionForm form, HttpServletRequest request,HttpServletResponse response) {
request.setAttribute("page", aaa());
return mapping.findForward("aaaa");
}
<html id="此页面就是返回的aaaa">
<a href="${a}">1</a> <a href="${b}">2</a> <a href="${c}">3</a> <a href="${d}">4</a>
<html>
Map<String,String> page=new HashMap<String, String>();
page.put("a", "1.html");
page.put("b", "2.html");
page.put("c", "3.html");
page.put("d", "4.html");
request.setAttribute("page",page);
<a href="${page[a]}">1</a> <a href="${page[b]}">2</a> <a href="${page[c]}">3</a> <a href="${page[d]}">4</a>