且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何防止JSF2注入隐藏的javax.faces.ViewState

更新时间:2023-09-10 14:19:34

不是Mojarra在做,而是PrimeFaces在做.尝试用<f:ajax>调用<h:commandButton>,您将看到它仅更新按钮最初所在的表单的视图状态.

It's not Mojarra who's doing that, it's PrimeFaces who's doing that. Try invoking a <h:commandButton> with <f:ajax> and you'll see that it only updates the view state of the form where the button originally resides in.

您可能需要向PrimeFaces员工报告他们应该在问题 Ajax更新不会触摸任何具有method="get"和/或没有<input type="hidden" name="formId" value="formId"><form>元素.

You may want to report an issue to the PrimeFaces guys that they should during ajax updates not touch any <form> elements which have a method="get" and/or do not have an <input type="hidden" name="formId" value="formId">.

在他们解决该问题之前,***的选择是在提交纯HTML表单时删除该元素.

Until they get it fixed, your best bet is to remove the element on submit of the plain HTML form.

<form onsubmit="form.removeChild(document.getElementById('javax.faces.ViewState'))">