首页 > 解决方案 > 为什么 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">

我在这方面找不到任何东西的原因是什么?

标签: codeigniter

解决方案


它已经记录在这里(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 包含在问题中(对您下一个问题的建议)。


推荐阅读