model-view-controller

MVC and dependency injection, forced to use singleton Controller?

两盒软妹~` 提交于 2020-01-02 07:33:10
问题 I'm working on building a PHP framework that behaves according to MVC principles and utilizes dependency injection. I think I have the front-controller part down; there is a working router that instantiates a controller instance and calls the appropriate action based on the requested URI. Next up is dependency injection. I want to implement a Container that resolves dependencies using reflection. In doing so, I think I'm running into a problem with my controllers. There are a number of what I

Creating urls with asp.net MVC and RouteUrl

谁说我不能喝 提交于 2020-01-02 07:11:15
问题 I would like to get the current URL and append an additional parameter to the url (for example ?id=1) I have defined a route: routes.MapRoute( "GigDayListings", // Route name "gig/list/{year}/{month}/{day}", // URL with parameters new { controller = "Gig", action = "List" } // Parameter defaults ); In my view I have a helper that executes the following code: // Add page index _helper.ViewContext.RouteData.Values["id"] = 1; // Return link var urlHelper = new UrlHelper(_helper.ViewContext);

Spring mvc add multiple rows

落爺英雄遲暮 提交于 2020-01-02 07:04:05
问题 i need your help as the title says i have a problem inserting multiple rows from a jsp form. The code is from an answer from this site. Controller @ModelAttribute("programform") public ProgramForm populatePojos() { // Don't forget to initialize the pojos list or else it won't work ProgramForm programform = new ProgramForm(); List<Programs> programs = new ArrayList<Programs>(); for(int i=0; i<2; i++) { programs.add(new Programs()); } programform.setPrograms(programs); return programform; }

PagedList.Core.Mvc PagedListPager Html extension in .Net Core is not there

天大地大妈咪最大 提交于 2020-01-02 06:49:33
问题 It seems like the PagedList.Core does not contain the extension method for Html helper, so I cannot use the code below: @Html.PagedListPager(Model, page => Url.Action("Index", new { page }), PagedListRenderOptions.MinimalWithItemCountText) I was able to successfully implement the paging in previous version of MVC, but it does not work in ASP.Net Core. Below I have attached IL Dasm reference. Am I missing something, or is there any other way to implement that? PagedList.Mvc: PagedList.Core.Mvc

Controller Action Methods with different signatures

我们两清 提交于 2020-01-02 06:41:49
问题 I am trying to get my URLs in files/id format. I am guessing I should have two Index methods in my controller, one with a parameter and one with not. But I get this error message in browser below. Anyway here is my controller methods: public ActionResult Index() { return Content("Index "); } public ActionResult Index(int id) { File file = fileRepository.GetFile(id); if (file == null) return Content("Not Found"); else return Content(file.FileID.ToString()); } Update: Done with adding a route.

Can somebody post a good example of MVC Pattern in Swift? [closed]

℡╲_俬逩灬. 提交于 2020-01-02 06:34:07
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . A simple project which has implemented the MVC pattern. So far,I have a brief understanding of how it is like but I want to see the practical implementation. 回答1: This is a typical example of Model View Controller in swift: class Article { var title: String var body: String var date: NSDate var thumbnail: NSURL

Why is my JSP view not being resolved?

寵の児 提交于 2020-01-02 06:07:53
问题 My dispatcher-servlet.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework

Horizontal scaling: routing user-generated subdomains between servers

左心房为你撑大大i 提交于 2020-01-02 04:11:06
问题 I maintain a web application that is outgrowing a single VPS. The architecture consists of a large number of small users, each with their own subdomain. Users do not interact. Load means i have to move some users, and all new users, to another installation of the web application on a separate server. Currently, every user subdomain falls to the same virtualhost, where a single PHP front controller displays the appropriate content based on the hostname. A single wildcard DNS record for *

mvc no codebehind strongly typed viewdata headers not working

旧巷老猫 提交于 2020-01-02 04:07:28
问题 I add that to my header <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> and am able to access ViewData and all its internals as well as all the mvc objects like url and html. As soon as I add " System.Web.Mvc.ViewPage<app.Models.tTable> " I have no access to any mvc classes and helper methods. I am confused on why this is. I have done an upgrade from mvc preview 5 to rc1 recently but my transition to rc1 was flawless without any errors

hibernate HQL createQuery() list() type cast to model directly

会有一股神秘感。 提交于 2020-01-02 03:46:06
问题 When I use list() of Hibernate (HQL) after createQuery(), then I want to directly type cast List<Object[]> to my List<POJO class> . I describe my actual scenario here. I have 3 Plain Old Java Objects say Person, Operation and Project and a table say Transaction with foreign references to Person , Operation and Project. class Person { String name; // getters and setters } class Operation { String name; // getters and setters } class Project { String name; // getters and setters } class