gpt4 book ai didi

java - 如何将消息从 servlet 传递到引导模式

转载 作者:行者123 更新时间:2023-12-02 11:01:49 25 4
gpt4 key购买 nike

以下是 servlet 部分,我在其中获取结果值。所以我需要以模式显示这个结果,请在这种情况下提供帮助,因为我是新手。

protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

Services service = new Services();

String dsid = request.getParameter("dsid");
String name = request.getParameter("name");
String superadmin = request.getParameter("gridRadios");
Boolean admin = null;
if (superadmin.equalsIgnoreCase("Yes")) {
admin = true;
} else {
admin = false;
}
String region = request.getParameter("region");

String result = service.addAssociate(dsid, name, admin, region);

// System.out.println("Result: " + result);
response.getWriter().write(result);



//I need to show value of 'result' in bootstrap modal


}

}

这是我想要显示结果值的模式:

<div class="modal fade" id="success_msg" role="dialog" tabindex="-1">
<div class="success">
<div class="modal-dialog-success">
<div class="col-xs-12 pade_none">
<button type="button" class="close" onClick="closeConfirm();" data-dismiss="modal">&times;</button>
<div class="col-xs-12 pade_none">
<p>Message to be shown over here</p>
</div>
<div class="col-xs-12 pad_none">
</div>
</div>
</div>
</div>
</div>

最佳答案

而不是response.getWriter().write(result)您需要将请求转发到目标页面。

RequestDispatcher dispatcher= request.getRequestDispatcher("/target.jsp");
request.setAttribute("result",result);

dispatcher.forward(request,response);

在您的 target.jsp 中

<!--omit bootstrap boilerplate-->
<!--use jstl-->
<c:out value="${requestScope.result}"></c:out>

<%
String result = (String)request.getAttribute("result");
%>


<!--omit bootstrap boilerplate-->
<%=result%>

关于java - 如何将消息从 servlet 传递到引导模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51279763/

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