如何使用 request.setAttribute 传递变量并发送到另一个页面

how to pass a variable using request.setAttribute and send to a another page

我正在使用 struts1。 我的动作类有代码

String data = "hi";
request.setAttribut("Data",data);

然后我

return "success";

我的struts.xml有

<action path="/Name" type="example.NameAction" >
<forward name="success" path="/displayname.jsp"/>
</action>

我用jstl在displayname.jsp中打印变量但是变量不是printed.how不使用sessionvariable.i传递一个变量给jsp想用request.setAttribute.

尝试Thi.it 将帮助您获取变量名称。

<input type="hidden" name="filePath" id="filePath" value="${filePath}"/> OR
<%String filePath = (String)request.getAttribute("filePath");%>

我将 struts-config.xml 操作 forward redirect=true 更改为 redirect=false.then 它工作正常。