我的代码在 REPL 中运行良好,但在我的 Web 应用程序中没有获得第二个值。
例如(?vehicle=bike&vehicle=car)
我试过的
当我做
- CL-用户>
(setf |vehicle| '(a b c)
- CL-用户>
(let ((|vehicle| (multival-plist:getf-all `(:|vehicle| ,|vehicle|) :|vehicle|))) (print (alexandria:flatten (list :vehicle |vehicle|))))
这会产生所需的输出(:VEHICLE A B C)
但是当我提交表格时
<form action="/checkbox">
<input type="checkbox" name="vehicle" value="bike"> I have a bike<br>
<input type="checkbox" name="vehicle" value="car"> I have a car<br>
<input type="submit" value="Submit">
</form>
到我的路线
@route GET "/checkbox"
(lambda (&key |vehicle|)
(let ((|vehicle| (multival-plist:getf-all `(:|vehicle| ,|vehicle|) :|vehicle|)))
(format nil "~a" (list :vehicle (alexandria:flatten |vehicle|)))))
实际上我将结果渲染到 djula 模板,但是为了测试我使用format
了。
<ul>
{% for a in vehicle %}
<li>{{ a }}</li>
{% endfor %}
</ul>
结果只(VEHICLE (bike))
检查了其中两个,导致
- 自行车
我期望发生的事情
输出应该
- 自行车
- 车
我将在我的应用程序中使用 16 个复选框,这将导致链接很长,任何建议使链接变短。
PS:我使用 Hunchentoot 服务器和 Caveman2 网络框架。