gpt4 book ai didi

java - JSP:setProperty 将值设置为变量

转载 作者:行者123 更新时间:2023-12-01 17:01:47 28 4
gpt4 key购买 nike

所以基本上我想弄清楚是否可以将 jsp:setProperty 函数中的值设置为在先前的 scriptlet 中声明的字符串变量。

我的代码如下。提前非常感谢:)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%
String type = request.getParameter("type");
%>
<title><% out.println(type);%> </title>
</head>

<jsp:useBean id="myBean" scope="session" class="org.geeks.Second"/>
<jsp:setProperty name="myBean" property="type" value=""/>

最佳答案

所以我设法解决了这个问题。经过反复试验,我发现我可以将脚本注入(inject)到如下所示的值中。

<jsp:setProperty name="myBean" property="type" value="<%= type %>"/>

关于java - JSP:setProperty 将值设置为变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61501235/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com