controller

Accessing Spring MVC DI beans from jsp

只谈情不闲聊 提交于 2019-12-17 15:29:32
问题 In some MVC frameworks you can call controller action from the view if you wish to execute some code and render some partial view. I'm not sure what is the correct way to do it in Spring MVC I want to have set of JSP templates. Some of them will be page layouts some of them will be small components like paginator, login box, menu, tag cloud etc etc etc. Each of these component need some beans or controller action to set some data into ViewAndModel so that view could use it. The problem is I

Nested controller issue in Java FX

左心房为你撑大大i 提交于 2019-12-17 14:55:08
问题 I'm trying to include controller( SelectedIssueController ) in my main layout ( main.fxml ). But I get the following error: Can not set lt.mypackage.controllers.SelectedIssueController field lt.mypackage.controllers.MainController.selectedIssueController to javafx.scene.layout.VBox Line in main.fxml: <fx:include fx:id="selectedIssueController" source="controllers/selectedissue.fxml" /> My selectedissue.fxml: <VBox xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx

passing JSON data to a Spring MVC controller

北慕城南 提交于 2019-12-17 10:19:51
问题 I need to send a JSON string to Spring MVC controller.But I do not have any form bindings to it , I just need to send a plain JSON data to Controller class.I am making jQuery AJAX call to the Controller method like the below code. $.ajax ({ url: "./save", type: "POST", data: JSON.stringify(array), dataType: "json", contentType: "application/json; charset=utf-8", success: function(){ alert("success "); } }); But how do I retrieve it in the Controller method?(Note: It is just plain JSON data

change controller name convention in ASP.NET MVC

限于喜欢 提交于 2019-12-17 09:54:09
问题 Is there a way to change the naming convention for controllers in ASP.NET MVC? What I want is to name my controllers InicioControlador instead of InicioController , or better yet, use a prefix instead of a suffix, and have ControladorInicio as my controller name. From what I have read so far, I think I have to implement my own Controller Factory. I would be very grateful if any of you could point me in the right direction. 回答1: Yes, ControllerFactory is the best solution of your problem.

Rails: access controller instance variable in CoffeeScript or JavaScript asset file

心已入冬 提交于 2019-12-17 08:31:43
问题 In Rails 3.1 it is not possible to access controller instance variables in an asset js.erb or coffee.erb file using syntax such as <%= @foo %>, where @foo is set in the controller. So then the question is what are the best ways for passing controller variables to CoffeeScript or JavaScript assets. This question has kind of been asked in multiple convoluted forms on the forum, but my point in asking it again is to have a place where all recommendations are gathered together, and the code

codeigniter check for user session in every controller

徘徊边缘 提交于 2019-12-17 08:23:37
问题 I have this private session in one of my controllers that checks if a user is logged in: function _is_logged_in() { $user = $this->session->userdata('user_data'); if (!isset($user)) { return false; } else { return true; } } Problem is that I have more than one Controller. How can I use this function in those other controllers? Redefining the function in every Controller isn't very 'DRY'. Any ideas? 回答1: Another option is to create a base controller. Place the function in the base controller

In Spring MVC, how can I set the mime type header when using @ResponseBody

安稳与你 提交于 2019-12-17 07:01:27
问题 I have a Spring MVC Controller that returns a JSON String and I would like to set the mimetype to application/json. How can I do that? @RequestMapping(method=RequestMethod.GET, value="foo/bar") @ResponseBody public String fooBar(){ return myService.getJson(); } The business objects are already available as JSON strings, so using MappingJacksonJsonView is not the solution for me. @ResponseBody is perfect, but how can I set the mimetype? 回答1: I would consider to refactor the service to return

Can Spring Security use @PreAuthorize on Spring controllers methods?

南楼画角 提交于 2019-12-17 03:03:53
问题 Can Spring Security use @PreAuthorize on Spring controllers methods? 回答1: Yes, it works fine. You need <security:global-method-security pre-post-annotations="enabled" /> in ...-servlet.xml . It also requires CGLIB proxies, so either your controllers shouldn't have interfaces, or you should use proxy-target-class = true . 回答2: See Spring Security FAQ (emphasis mine). In a Spring web application, the application context which holds the Spring MVC beans for the dispatcher servlet is often

ASP.NET MVC - Should business logic exist in controllers?

人盡茶涼 提交于 2019-12-17 02:53:27
问题 Derik Whitaker posted an article a couple of days ago that hit a point that I've been curious about for some time: should business logic exist in controllers? So far all the ASP.NET MVC demos I've seen put repository access and business logic in the controller. Some even throw validation in there as well. This results in fairly large, bloated controllers. Is this really the way to use the MVC framework? It seems that this is just going to end up with a lot of duplicated code and logic spread

javafx using objects from MainController or other Controllers in proper Controller class

僤鯓⒐⒋嵵緔 提交于 2019-12-17 02:51:34
问题 I have following code: package pl.javastart.youtufy.controller; import java.net.URL; import java.util.ResourceBundle; import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.Node; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.ToggleButton; import javafx.scene.web.WebEngine; import javafx.stage.Stage; public class