codeigniter - 为什么 Codeigniter 在表单操作中自动添加 .html?
问题描述
我的控制器中有以下代码:
$data['action']='contact/add';
$this->load->view('inc/header');
$this->load->view('contact',$data);
$this->load->view('inc/footer');
当我加载我的视图页面时,它会呈现以下表单元素:
<form
action="http://someurl.com/index.php/Booknow/add.html"
id="registrationform"
class="row" name="registrationform"
method="post"
accept-charset="utf-8">
我在这方面找不到任何东西的原因是什么?
解决方案
它已经记录在这里(Url 后缀配置),原因是它在配置上,而不是在你的控制器、视图或 HTML 中。
With empty url suffix:
site_url('foo/bar'): http://localhost/ap.programming/foo/bar
base_url('bar/bas'): http://localhost/ap.programming/bar/bas
With '.jsp' as url suffix:
site_url('foo/bar'): http://localhost/ap.programming/foo/bar.jsp
base_url('bar/bas'): http://localhost/ap.programming/bar/bas
PS:
故意不考虑 Codeigniter 4。
注意:最好将 PHP 视图(未渲染的 HTML)和渲染的 HTML 包含在问题中(对您下一个问题的建议)。
推荐阅读
- pytorch - 矩阵乘法的后向推进
- excel - 使用 Applescript 更改 Excel 中某些单元格的背景颜色
- c++ - 如何从默认构造函数获取值到控制台?
- c# - 可以将模拟配置为在任何方法调用上引发指定的异常吗?
- java - Java - Thread.sleep VS Awaitility.await()
- flutter - 如何在颤动中使用导航器绕过屏幕?
- mariadb - 无法在 macOS Big Sur (Apple M1) 上保护 MariaDB 安装
- django - 使用请求的内容在 Django admin 中定义 ModelForm 的初始值
- r - 在if语句中使用R中的变量名访问列,条件长度> 1
- php - JSON 数据的动态 SQL 插入 [PHP]