简体   繁体   English

发布/重定向/获取模式和粘性表单

[英]Post/Redirect/Get pattern and sticky forms

I'm using the Post/Redirect/Get pattern on a form of mine. 我在我的一个表格上使用Post / Redirect / Get模式。 I've never used this approach before and I'm trying to figure something out: 我之前从未使用过这种方法,而且我正试图弄清楚:

Normally, I always just display the posted form again when there are validation errors and display POST values in the form (sticky form). 通常,当出现验证错误并在表单中显示POST值(粘性形式)时,我总是只显示已发布的表单。 However, with the PRG pattern, the form is displayed after a redirect, so there aren't any POST values. 但是,使用PRG模式时,表单会在重定向后显示,因此没有任何POST值。

So my question is, how can I implement the PRG pattern and still have sticky forms? 所以我的问题是, 如何实现PRG模式并且仍然具有粘性形式?

Why are you redirecting if validation fails? 如果验证失败,为什么要重定向? You should redirect only on success, and keep your sticky form on failure. 您应该仅在成功时重定向,并保持您的粘性表单失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM