springboot怎么把数据传给前端:springboot 如何引入前端 bootstrap?
这种问题网上一搜一大堆,你可以具体找一篇文章试试,遇到问题可以针对相关问题去提问。springboot通过jar包方式引入bootstrap_个人文章 - SegmentFault 思否 这不是查查就
顺晟科技
2022-10-19 11:51:46
18
你好, 下面的代码段旨在询问用户是否想成为我们博客网站的客座作者,但是radio切换总是返回零值。MYSQL列类型为tinyint(1)。
<!-- Author? -->
<div class="author" style="text-align: center; margin-bottom: 1rem;">
<h3><strong>Are you interested in earning money blogging for us?</strong></h3>
<div class="form-check-inline">
<input class="form-check-input" name="is_author" type="radio" value="true" id="is_author1" style="top: 0.1rem; width: 1.50rem; height: 1.50rem;">
<h4 class="form-check-label" for="is_author">Yes, please.</h4>
</div>
<div class="form-check-inline">
<input class="form-check-input" name="is_author" type="radio" value="false" id="is_author0" style="top: 0.1rem; width: 1.50rem; height: 1.50rem;">
<h4 class="form-check-label" for="is_author">No, thank you.</h4>
</div>
</div>
下面是控制器中引用“is_author”的方式:
<!-- Author? -->
<div class="author" style="text-align: center; margin-bottom: 1rem;">
<h3><strong>Are you interested in earning money blogging for us?</strong></h3>
<div class="form-check-inline">
<input class="form-check-input" name="is_author" type="radio" value="true" id="is_author1" style="top: 0.1rem; width: 1.50rem; height: 1.50rem;">
<h4 class="form-check-label" for="is_author">Yes, please.</h4>
</div>
<div class="form-check-inline">
<input class="form-check-input" name="is_author" type="radio" value="false" id="is_author0" style="top: 0.1rem; width: 1.50rem; height: 1.50rem;">
<h4 class="form-check-label" for="is_author">No, thank you.</h4>
</div>
</div>
提前感谢
顺晟科技:
您总是得到0的原因是您的radion按钮总是以字符串类型发送输入值。所以,它是“真的”而不是真的。因此,不能使用布尔验证规则验证“true”和“false”。因为它是一个字符串,验证规则总是失败。 在laravel 8 dock中,它清楚地提到“接受的输入是true、false、1、0、'1”和'0“。”(https://laravel.com/docs/8.x/validation#rule-boolean)
这样您就可以使用“1”为true,“0”为false来验证单选按钮, 新HTML代码,
<!-- Author? -->
<div class="author" style="text-align: center; margin-bottom: 1rem;">
<h3><strong>Are you interested in earning money blogging for us?</strong></h3>
<div class="form-check-inline">
<input class="form-check-input" name="is_author" type="radio" value="true" id="is_author1" style="top: 0.1rem; width: 1.50rem; height: 1.50rem;">
<h4 class="form-check-label" for="is_author">Yes, please.</h4>
</div>
<div class="form-check-inline">
<input class="form-check-input" name="is_author" type="radio" value="false" id="is_author0" style="top: 0.1rem; width: 1.50rem; height: 1.50rem;">
<h4 class="form-check-label" for="is_author">No, thank you.</h4>
</div>
</div>
我通过添加到数组中的模型来解决这个问题:
<!-- Author? -->
<div class="author" style="text-align: center; margin-bottom: 1rem;">
<h3><strong>Are you interested in earning money blogging for us?</strong></h3>
<div class="form-check-inline">
<input class="form-check-input" name="is_author" type="radio" value="true" id="is_author1" style="top: 0.1rem; width: 1.50rem; height: 1.50rem;">
<h4 class="form-check-label" for="is_author">Yes, please.</h4>
</div>
<div class="form-check-inline">
<input class="form-check-input" name="is_author" type="radio" value="false" id="is_author0" style="top: 0.1rem; width: 1.50rem; height: 1.50rem;">
<h4 class="form-check-label" for="is_author">No, thank you.</h4>
</div>
</div>
以前,所有值都作为我在数据库中设置的默认值返回,默认值为零。 希望这对将来的人有所帮助。
05
2022-12
02
2022-12
02
2022-12
29
2022-11
29
2022-11
24
2022-11