我添加了前缀admin并将控制器从 Userscontroller 更改为 LoginController ,现在 localhost:8765 / admin 工作正常但 localhost:8765 / admin / login / check_login 但是当我提交表单时,它会给我一个错误错误:在此服务器上找不到请求的地址'/ admin / login / check-login'其中 check_login是我的身份验证操作
路由器
'set up a for loop that increments through all sheets in the workbook
For i = 1 To ThisWorkbook.Sheets.Count
'set up a temp page to work with the current page
Set tem = ThisWorkbook.Sheets(i)
'increment through all the rows that have data in them
For Each rng In tem.Rows
'if the data matches what was searched for, copy it into another worksheet
If tem.Cells(ct, 4) = SForm.Text Then
sr.Cells(spot, 1) = tem.Cells(ct, 1)
sr.Cells(spot, 2) = tem.Cells(ct, 2)
sr.Cells(spot, 3) = tem.Cells(ct, 3)
sr.Cells(spot, 4) = tem.Cells(ct, 4)
sr.Cells(spot, 5) = tem.Cells(ct, 5)
sr.Cells(spot, 6) = tem.Cells(ct, 6)
sr.Cells(spot, 7) = tem.Cells(ct, 7)
sr.Cells(spot, 8) = tem.Cells(ct, 8)
sr.Cells(spot, 9) = tem.Cells(ct, 9)
sr.Cells(spot, 10) = tem.Cells(ct, 10)
sr.Cells(spot, 11) = tem.Cells(ct, 11)
sr.Cells(spot, 12) = tem.Cells(ct, 12)
'increment the placeholder for the new sheet
spot = spot + 1
End If
'increase ct to keep track of where in the worksheet it is
ct = ct + 1
Next rng
'reset ct for the next worksheet
ct = 1
Next i
App Controller
Router::prefix('admin', function ($routes) {
$routes->connect('/', ['controller' => 'Login', 'action' => 'display','login']);
});
检查登录操作
public function initialize() {
$this->loadComponent('Flash');
$this->loadComponent('Auth', [
'authenticate' => [
'Form' => [
'fields' => [
'username' => 'username',
'password' => 'password'
]
]
],
'loginAction' => [
'controller' => 'Login',
'action' => 'check_login',
'prefix' => 'admin'
],
]);
// Allow the display action so our pages controller
// continues to work.
$this->Auth->allow(['display']);
提前致谢
答案 0 :(得分:1)
你为什么复杂化?最简单的方法:
Admin
文件夹。 Admin
文件夹中的所有功能仅用于URL中的Admin
前缀。下一步 - 您可以使用以下路线将URL / admin / login映射到用户控制器的login()操作:
Router::prefix('admin', function ($routes) {
// Because you are in the admin scope,
// you do not need to include the /admin prefix
// or the admin route element.
$routes->connect('/login', ['controller' => 'Users', 'action' => 'login']);
});
这是最简单的方法。