model-view-controller 相关问题

模型 - 视图 - 控制器(MVC)是软件工程中使用的架构模式。对于Microsoft ASP.NET MVC,请改用[asp.net-mvc]或[asp.net-core-mvc]标签。对于Spring MVC,请改用[spring-mvc]标签。

一个视图中的多个模型 ASP.net core mvc

美好的一天。我在开发asp.net core mvc应用程序时遇到了问题。 事实上,我有一个仪表板页面,其数据取自@model DashboardPageViewModel。还有...

回答 1 投票 0

模型未从数据库获取数据

在我的 ASP.NET Core MVC 应用程序中,我想访问数据库,但我的代码返回错误。 无法理解,有什么问题。 程序.cs var builder = WebApplication.CreateBuilder(args); 建造者.Servi...

回答 1 投票 0

在 Visual Studio 2022 中创建空的 Asp.NET MVC 项目

我试图在 VS 2022 中创建一个空的 MVC 项目,但找不到真正的项目类型。当我选择“Asp.NET Web应用程序(模型-视图-控制器)”时,它不是空的。当我选择...

回答 3 投票 0

身份服务器4:为什么我收到unauthorized_client?

这是我的 mvc 与身份服务器连接的初始设置。 app.UseOpenIdConnectAuthentication(新 OpenIdConnectAuthenticationOptions { 认证...

回答 3 投票 0

在 MVC 中验证多个复选框

我的表单中有 4 个复选框,并希望用户在提交表单时至少选择其中一个复选框。 我正在使用“ExpressiveAnnotations.Attributes;”当我们在 p 的其他部分使用它时参考...

回答 1 投票 0

如何在Asp.net mvc中使用控制器的Json方法正确序列化C#长数字?

Mvc Controller.Json方法将长数3458764513820540917序列化为3458764513820541000。我需要具有int64属性的POCO。如何将 C# long 序列化为 json 字符串“3458764513820540917”?

回答 2 投票 0

Spring Boot Web 应用程序错误:在名为“dispatcherServlet”的 DispatcherServlet 中未找到带有 URI [/] 的 HTTP 请求的映射

我检查了有关此警告的其他问题,但没有人解决。 IDE:Spring工具套件3.9.4 Java:Oracle Java 8 当我尝试打开网页时显示错误页面: 尝试本地主机:8080 一个...

回答 1 投票 0

如何将此列表组织到 MVC 中?

我想列出我商店中最畅销的印刷品列表。 我有一个表(print_for_sale),其中包含 fk_sale_id 和 fk_print_id,我可以在其中查看已购买了多少张印刷品。 我想出了这个...

回答 1 投票 0

如何在 html 文件中覆盖 :before 属性值

这是我的代码: 李某:之前{ 过渡:全部 0.2 秒缓入缓出; 内容: ””; 显示:块; 宽度:0; 高度:0; 边框样式:实心; 边框宽度:11px 5px 11px 0; 边框...

回答 2 投票 0

具有动态参数的 Codeigniter 视图

我从控制器加载多个视图,以显示页面。 $this->load->view('header'); $this->load->view('内容', $data); $this->load->view('sidebar1', $data1); $

回答 3 投票 0

公共文件夹内的静态文件在 PHP MVC 架构中不起作用

我的项目结构 核 路由器.php http 控制器 索引.php 民众 CSS js 图像 索引.php 意见 路线.php 索引.php代码 我的项目结构 核心 路由器.php http 控制器 index.php 公众 CSS js img index.php 浏览量 routes.php index.php代码 <?php use Core\Router; const BASE_PATH = __DIR__.'/../'; session_start(); require BASE_PATH.'vendor/autoload.php'; require BASE_PATH.'Core/functions.php'; require BASE_PATH.'bootstrap.php'; $router = new Router(); require BASE_PATH.'routes.php'; $uri = parse_url($_SERVER['REQUEST_URI'])['path']; $method = $_POST['_method'] ?? $_SERVER['REQUEST_METHOD']; try { $router->route($uri, $method); } catch (Exception $e) { echo $e->getMessage(); } Router.php代码 <?php namespace Core; use Core\Middleware\Middleware; use Exception; use JetBrains\PhpStorm\NoReturn; class Router { protected array $routes = []; public function get($uri, $controller): void { $this->add('GET', $uri, $controller); } public function add($method, $uri, $controller): static { $this->routes[] = [ 'uri' => $uri, 'controller' => $controller, 'method' => $method, 'middleware' => null ]; return $this; } public function post($uri, $controller): void { $this->add('POST', $uri, $controller); } public function delete($uri, $controller): static { return $this->add('DELETE', $uri, $controller); } public function patch($uri, $controller): static { return $this->add('PATCH', $uri, $controller); } public function put($uri, $controller): static { return $this->add('PUT', $uri, $controller); } public function only($key): static { $this->routes[array_key_last($this->routes)]['middleware'] = $key; return $this; } /** * @throws Exception */ public function route($uri, $method) { foreach ($this->routes as $route) { if ($route['uri'] === $uri && $route['method'] === strtoupper($method)) { Middleware::resolve($route['middleware']); return require base_path('Http/controllers/'.$route['controller']); } } $this->abort(); } #[NoReturn] protected function abort($code = 404): void { http_response_code($code); require base_path("views/{$code}.php"); die(); } public function previousUrl() { return $_SERVER['HTTP_REFERER']; } } routes.php代码 <?php /** @var Router $router */ use Core\Router; $router->get('/', 'index.php'); $router->get('/contact', 'contact.php'); $router->get('/about', 'about.php'); $router->get('/service', 'service.php'); $router->get('/menu', 'menu.php'); $router->get('/team', 'team.php'); $router->get('/testimonial', 'testimonial.php'); $router->get('/booking', 'booking/booking.php'); $router->get('/register', 'register/create.php'); $router->get('/login', 'session/create.php'); $router->get('/cart', 'cart/index.php'); 公共文件夹中存在的所有静态文件和库,当我调用它们时,它们在项目中的其他页面上不起作用。 我使用 php -S lcoalhost:8080 在公共文件夹中运行项目。 我尝试更改静态文件的路径,但它不起作用,我也尝试将 .htaccess 添加到项目中,但也不起作用 那是因为 PHP 的内置“服务器”并不是真正的服务器(因为缺乏更好的描述)。您应该学习如何使用 Docker 设置 nginx/FPM 服务器。 但是,短期内,您可以创建一个单独的文件,在针对 index.php 运行之前尝试加载现有文件。 您将服务器初始化命令更改为: php -S 127.0.0.1:8080 ./public/built-in.php 这有点像在这个练习中(有点过时了,但它应该解释了这个想法)。

回答 1 投票 0

公共文件夹内的静态文件在 PHP MVC 架构中不起作用

我的项目结构 核 路由器.php http 控制器 索引.php 民众 CSS js 图像 索引.php 意见 路线.php 索引.php代码 我的项目结构 核心 路由器.php http 控制器 index.php 公众 CSS js img index.php 浏览量 routes.php index.php代码 <?php use Core\Router; const BASE_PATH = __DIR__.'/../'; session_start(); require BASE_PATH.'vendor/autoload.php'; require BASE_PATH.'Core/functions.php'; require BASE_PATH.'bootstrap.php'; $router = new Router(); require BASE_PATH.'routes.php'; $uri = parse_url($_SERVER['REQUEST_URI'])['path']; $method = $_POST['_method'] ?? $_SERVER['REQUEST_METHOD']; try { $router->route($uri, $method); } catch (Exception $e) { echo $e->getMessage(); } Router.php代码 <?php namespace Core; use Core\Middleware\Middleware; use Exception; use JetBrains\PhpStorm\NoReturn; class Router { protected array $routes = []; public function get($uri, $controller): void { $this->add('GET', $uri, $controller); } public function add($method, $uri, $controller): static { $this->routes[] = [ 'uri' => $uri, 'controller' => $controller, 'method' => $method, 'middleware' => null ]; return $this; } public function post($uri, $controller): void { $this->add('POST', $uri, $controller); } public function delete($uri, $controller): static { return $this->add('DELETE', $uri, $controller); } public function patch($uri, $controller): static { return $this->add('PATCH', $uri, $controller); } public function put($uri, $controller): static { return $this->add('PUT', $uri, $controller); } public function only($key): static { $this->routes[array_key_last($this->routes)]['middleware'] = $key; return $this; } /** * @throws Exception */ public function route($uri, $method) { foreach ($this->routes as $route) { if ($route['uri'] === $uri && $route['method'] === strtoupper($method)) { Middleware::resolve($route['middleware']); return require base_path('Http/controllers/'.$route['controller']); } } $this->abort(); } #[NoReturn] protected function abort($code = 404): void { http_response_code($code); require base_path("views/{$code}.php"); die(); } public function previousUrl() { return $_SERVER['HTTP_REFERER']; } } routes.php代码 <?php /** @var Router $router */ use Core\Router; $router->get('/', 'index.php'); $router->get('/contact', 'contact.php'); $router->get('/about', 'about.php'); $router->get('/service', 'service.php'); $router->get('/menu', 'menu.php'); $router->get('/team', 'team.php'); $router->get('/testimonial', 'testimonial.php'); $router->get('/booking', 'booking/booking.php'); $router->get('/register', 'register/create.php'); $router->get('/login', 'session/create.php'); $router->get('/cart', 'cart/index.php'); 公共文件夹中存在的所有静态文件和库,当我调用它们时,它们在项目中的其他页面上不起作用。 我使用 php -S lcoalhost:8080 在公共文件夹中运行项目 我尝试更改静态文件的路径,但它不起作用,我也尝试将 .htaccess 添加到项目中,但也不起作用 那是因为你的 php 内置的“服务器”并不是真正的服务器(因为缺乏更好的描述)。您应该学习如何使用 docker 设置 nginx/fpm 服务器。 但是,简而言之,您可以创建一个单独的文件,在针对 index.php 运行之前尝试加载现有文件。 您将服务器初始化命令更改为: php -S 127.0.0.1:8080 ./public/built-in.php 有点像这个练习(有点过时,但应该解释一下这个想法)。

回答 1 投票 0

如何访问 Umbraco Web 模型链接

所以我正在重建一个最初位于 Umbraco 7 上的旧网站,并将其放到 Umbraco 8 上(是的,我知道它也接近 EOL,这只是为了安全措施) 我遇到的问题是...

回答 1 投票 0

如何禁用MVC按钮以便F12无法覆盖

正如标题所说,这可能吗?我有一个项目,在某些情况下,我需要禁用页面上的按钮。我已经为它设置了一个标志并在控制器中进行了一些检查......

回答 1 投票 0

sql 难以计算一列并获取具有相同内容的最旧的 id

我正在 mvc .net core 中制作一个学校项目,人们应该能够发送请求帮助并将其显示在屏幕上,我的困难来自于其他人应该做的部分......

回答 1 投票 0

mvc中数组到字符串的转换

我是 PHP MVC 的新手,目前正在学习路由和控制器。这是我的错误: 警告:C:\xampp\htdocs\phpmvc p 中的数组到字符串转换

回答 0 投票 0

flutter中MVC和MVVM的区别

我不明白mvc和mvvm之间的区别! 有人可以帮我解释一下吗? 在MVC中: 模型 类用户模型{ 迟到的 int id; 迟到的字符串名称; 迟到的字符串电子邮件; 用户模型({要求...

回答 2 投票 0

使用 CodeIgniter 将两个数据库表中的相关数据作为二维数组传递到视图层

我有两个查询$q1和$q2。从 query1 中,我得到多条记录,每条记录都有一个 id。我想在第二个查询的 where 条件中使用这个 id。 这是我的控制器代码,它使用...

回答 3 投票 0

通过 C# MVC API 执行查询

我在某些代码上遇到了问题,我似乎无法弄清楚这一点。我正在尝试将一些数据发送到连接到我们的 SQL Server 的后端 API 并执行我不执行的查询...

回答 1 投票 0

如何使用字符串重定向到操作

我是 MVC 新手,因此希望对以下方面有任何帮助。 我有一个用于登录的 AuthController,如果有 returnUrl,我想返回到该 url。似乎正在寻找当前...

回答 2 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.