1, illegal request: Index/user/addlist
Use two similar URLs to request two methods separately
These two methods:
Public function Add6 () {
$user [' nickname '] = "Chen Liu";
$user [' email '] = "[email protected]";
$user [' birthday '] = strtotime ("1993-12-12");
if ($result = Usermodel::create ($user)) {
return "User [". $result->nickname. ":". $result->id. "] New Success ";
}else{
return Usermodel::geterror ();
}
}
Public function Addlist () {
$user = new Usermodel;
$userlist = [
[' nickname ' + ' Zhou Eight ', ' email ' = ' [email protected] ', ' Birthday ' =>strtotime (' 1991-04-20 ')],
[' nickname ' + ' summer Nine ', ' email ' = ' [email protected] ', ' Birthday ' =>strtotime (' 1990-02-28 ')],
];
if ($user->saveall ($userlist)) {
return "User batch new success";
}else{
return "User batch add error";
}
}
Routing rules:
return [
' __pattern__ ' = [
' name ' = ' \w+ ',
],
' [Hello] ' = [
': id ' = [' Index/hello ', [' method ' = ' get '], [' id ' = ' \d+ '],
': name ' = = [' Index/hello ', [' method ' = ' post ']],
],
' user/index ' = ' index/user/index ',
' user/create ' = ' index/user/create ',
' user/add ' = ' index/user/add ',
' user/add_list ' = ' index/user/addlist ',
' user/update/:id ' = ' index/user/update ',
' user/delete/:id ' = ' index/user/delete ',
' user/:id ' = ' index/user/read ',
];
The Final Solution: Delete the "user/add_list" and "Index/user/addlist" in the routing rules. Although I don't know why it is wrong here.
thinkphp Error Accumulation and summary