如何使用struts1标记在jsp中检索请求范围值?
下面是我如何设置请求范围的值。并且无法在java脚本中检索警报,需要一些帮助如何使用struts1标记在jsp中检索请求范围值?,jsp,scriptlet,struts1,Jsp,Scriptlet,Struts1,下面是我如何设置请求范围的值。并且无法在java脚本中检索警报,需要一些帮助 `request. set Attribute ("token", token);` 我是这样用的 但是没有运气 您可以在head标签中添加以下代码 此代码从请求中获取令牌值并将其设置为局部变量 <% String token = request.getAttribute("token").toString(); %> <script
`request. set Attribute ("token", token);`
我是这样用的
但是没有运气 您可以在head标签中添加以下代码 此代码从请求中获取令牌值并将其设置为局部变量
<%
String token = request.getAttribute("token").toString();
%>
<script type="text/javascript">
var tokenValue = "<%=token%>";
alert(tokenValue);
</script>
此代码从局部变量获取值,并将其设置为javascript变量
<%
String token = request.getAttribute("token").toString();
%>
<script type="text/javascript">
var tokenValue = "<%=token%>";
alert(tokenValue);
</script>
var-tokenValue=“”;
警报(令牌值);
我还尝试直接从请求范围读取,如下所示,alert(${requestScope.token})&工作正常。很高兴听到这个消息。选择它作为可接受的答案,这样,如果其他人有相同的问题,它将帮助他们。