model-view-controller

Spring Boot - set value from an external properties file

可紊 提交于 2019-12-24 20:04:35
问题 I have an external location set on my application.properties as below spring.config.location=file:${catalina.home}/conf/app.properties app.properties has a property as timeOut=10000 . There are many other properties as well. I need to set this property on my session something like this: session.setMaxInactiveInterval(timeOut_Property); How can this be achieved? Adding Controller: @Controller public class StartController { @Value("${spring.config.location.defaultTimeout}") private int

Navigate from 1 page to another on table row click using react

别等时光非礼了梦想. 提交于 2019-12-24 19:32:42
问题 Hi Following from stack over flow question , Map() not a funtion when calling MVC end point using react, I want to navigate from one page to another. I have read about react router, but not sure how to use them. So if the first page just displays the roomids, I want to be able to click on it and show the available Orange/apple etc on a different page. Is this possible? Thanks in advance. 来源: https://stackoverflow.com/questions/54810915/navigate-from-1-page-to-another-on-table-row-click-using

Exception after updating from preview to .net core 3.0 release

主宰稳场 提交于 2019-12-24 19:05:27
问题 I got this error in the browser after updating to .net core release 3.0 : TypeLoadException: Could not load type 'System.Diagnostics.CodeAnalysis.MaybeNullAttribute' from assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 I've updated everything to latest version 3.0. Is it a bug? What should i do? 回答1: This error occurred when using preview SDK of .NET Core. Based on this git thread: Make sure all .net core runtimes and SDKs are uninstalled. Run dotnet -

IRepository, IService, Unity in an ASP.NET MVC Application, reference question

可紊 提交于 2019-12-24 18:53:22
问题 I'm new to Unity, but this question is more generic to IoC, and I’m pretty new to implementing IoC as a whole. I have VS2010 solution with this project structure (simplified slightly): Business Objects – Folder DomainModel (Class Lib prj.) – Entity Framework 2 POCO entities Data Layer – Folder DataAccess (Class Lib prj.) – EF2 EDMX Repository (Class Lib prj.) – IRepository interface & repository concrete implementations Presentation Layer – folder WebUI – MVC Project Service Layer Service

how do I create a custom WebGrid Column

被刻印的时光 ゝ 提交于 2019-12-24 18:17:17
问题 i need to add an additional column to my WebGrid, the new colume should contain an HTML5 audio based on one of the record's fields. something like that: <audio controls="controls"> <source src="@string.Format("{0}{1}", @item.SongID.ToString(), ".mp3")" type="audio/mp3"/> Your browser does not support the audio element. </audio> does webgrid supports such a scenario? Thank! ofer 回答1: Here's one way of doing it. Inside your view create a helper and use it for column format: @helper AudioTag

How to Use Module Controllers in Kohana 3?

情到浓时终转凉″ 提交于 2019-12-24 17:28:45
问题 For the following application directory structure under / in Kohana 3: application classes controller controller1.php modules admin classes controller controller2.php And the urls be: /controller1 and /admin/controller2? I seem to be missing something though because I keep getting a 404 error with the /admin/controller. What am I doing incorrectly? The exact error is: HTTP_Exception_404 [ 404 ]: The requested URL admin/borrowers was not found on this server. And I don't have any custom routes

How to validate uploaded files by FluentValidation

喜你入骨 提交于 2019-12-24 17:10:31
问题 How can I validate uploaded files using FluentValidation? <input type="file" asp-for="Files" multiple /> 回答1: your ViewModel must have public IList<IFormFile> Files { get; set; } : public class CustomViewModel { public IList<IFormFile> Files { get; set; } ... } you must create a validator for IFormFile type as below: public class FileValidator : AbstractValidator<IFormFile> { public FileValidator() { RuleFor(x => x.Length).NotNull().LessThanOrEqualTo(100) .WithMessage("File size is larger

How to pass IEnumerable model to controller

删除回忆录丶 提交于 2019-12-24 16:57:08
问题 My model is public class InvBrojeviModel { public int rb { get; set; } public int id_ulaz_sredstava { get; set; } public int? inv_broj { get; set; } public string serijski_broj { get; set; } public int id_sifra { get; set; } } I'm trying to pass this model to controller with an ajax call var m = '@Html.Raw(Json.Encode(Model))'; $.ajax({ url: "/Ulazna_Dokumenta/InvBrojevi_Post", type: 'POST', data: JSON.stringify(m), dataType: 'json', success: function (data) { alert("OK"); } }); I can see the

Return a value from a Firebase JS callback method (DAL) to another function (controller)

倾然丶 夕夏残阳落幕 提交于 2019-12-24 16:48:03
问题 I've been working on a simple chat application that will allow users to type messages in a simple group chat and have them update/display in real time. Because of this I have decided to use Firebase, and spent some time getting used to its web API. However, I've run into some issues when I try to manually create a simple user authentication system, or even just return a list of values to another function. I'm trying to follow an MVC pattern, with the HTML forms triggering event handlers

Call Action in Controller From View and send parameter

左心房为你撑大大i 提交于 2019-12-24 16:31:23
问题 I am trying to call a method inside a controller in MVC from a javascript action. The javascript action is supposed to invoke this method inside the controller and send some parameters to it. My Javascript code looks like this: location.href = '@Url.Content("~/Areas/MyArea/MyMethod/"+Model.MyId)'; My Method is defined as follows: [HttpGet] public ActionResult MyMethod(int? MyId) { doSomething(MyId); return View("MyView"); } However, when i debug the application, when the method is called the