controller

自己动手做框架—MVC+Front Controller

这一生的挚爱 提交于 2020-04-18 10:21:07
在我前面一篇博文《 逃脱Asp.Net MVC框架的枷锁,使用Razor视图引擎 》发表之后,很多人关心,脱离了之后怎么办?那么这可以说是它的续篇了。 同时,这也是 eLiteWeb 开源软件的一部分。 MVC + Front Controller 我们常常提到的MVC中作为Controller的C。其实有两项任务,一个是处理Http请求,另一个是对请求中的用户数据进行的处理。前者,有:安全认证,Url映射等。Front Controller 模式就是把这个C进一步分离。两个责任两个类(单一责任原则)。因此,这里给我的MVC模式,赋予新的内涵C => Command,以诠释两个模式的融合。 非我族类,拒之门外 --- 转换器BasicHttphandler 这是一个Adapter目的就是为了把ASP.Net环境转化为我自定义的Web抽象。 首先就是BasicHttphandler本身实现了IHttpHandler,并在Web.config中设置为默认的系统HttpHandler,把控制权拿了过来,我的世界我做主。 其次,把HttpContext转换为自定义的WebRequest,然后传递给Front Controller作进一步的处理处理。 public class BasicHttpHandler:IHttpHandler { public class

@Controller和@RestController的区别

放肆的年华 提交于 2020-04-14 23:48:33
【推荐阅读】微服务还能火多久?>>> 4.0重要的一个新的改进是@RestController注解,它继承自@Controller注解。4.0之前的版本,Spring MVC的组件都使用@Controller来标识当前类是一个控制器servlet。 使用这个特性,我们可以开发REST服务的时候不需要使用@Controller而使用专门的@RestController。 当你实现一个RESTful web services的时候,response将一直通过response body(即字符串)发送。为了简化开发,Spring 4.0提供了一个专门版本的controller。 官方文档解释: @RestController is a stereotype annotation that combines @ResponseBody and @Controller. 意思是: @RestController注解相当于@ResponseBody + @Controller合在一起的作用。 1) 如果只是使用@RestController,则方法无法返回jsp页面,配置的视图解析器InternalResourceViewResolver不起作用,返回的内容就是Return 里的内容,一般为JSON。 例如:本来应该到success.jsp页面的,则返回的就是“success”字符串了. 2)

Kubernetes部署服务

橙三吉。 提交于 2020-04-07 07:24:12
基本流程为: 做image 并且push到private registry 创建replication controller 创建service 搭建nginx代理 测试 下面详述: 1. 制作image java基础image: FROM dockerimages.yinnut.com:15043/centos:7 MAINTAINER xuelun-infra morgan.wu@yinnnut.com ADD jdk-8u60-linux-x64.tar.gz /usr/local/ ENV JAVA_HOME /usr/local/jdk1.8.0_60 ENV PATH $JAVA_HOME/bin:$PATH Friend-Service镜像: FROM dockerimages.yinnut.com:15043/yinnut-java:0.1 MAINTAINER xuelun-infra morgan.wu@yinnnut.com ADD FriendService.war / ADD jetty-runner.jar / WORKDIR / VOLUME ["/var/log"] 2. 创建Replication Controller rc.yaml文件, 创建了2个friend的pod,设置replicas为2 apiVersion: v1 kind:

Kubernetes管理基本教程

我的梦境 提交于 2020-04-06 22:00:51
本文不对Kubernetes做过多介绍,直接讲Kubernetes的各种YAML基本撰写规范。 基本概念请见: http://www.infoq.com/cn/articles/Kubernetes-system-architecture-introduction 所有的Resource的定义文档在这里都有 http://kubernetes.io/v1.0/docs/api-reference/definitions.html 例如:你要查询Pod声明里面有哪些字段,那么很有用. 不多废话。 1. 创建Container / Pod## Kubernetes的编排基本单元是Pod,故而哪怕你只有一个Container,也要创建一个Pod来容纳这个Container. apiVersion: v1 kind: Pod metadata: name: hello-world # pod资源名称,集群unique的 spec: # specification of the pod’s contents restartPolicy: Never # 运行这个容器一次,然后就结束这个pod containers: - name: hello # 只是这个container的nickname image: "ubuntu:14.04" # image 名, 默认使用Docker Hub

How to pass arguments in JavaFX

和自甴很熟 提交于 2020-03-26 11:03:03
问题 So, it's a little confusing but here is the thing: I created a window with SceneBuilder, and created the controller and everything, there is a button in the window. The button setOnAction() method makes the program open another window, the thing is, this other window is another class and I want to pass information to this other window, but it seems I cannot. Here's some code example: MainWindow: confirm.setOnAction(event->{ try { LibraryWindowController lwc = new LibraryWindowController();

failed to open stream: No such file or directory (Laravel)

只谈情不闲聊 提交于 2020-03-18 06:33:30
问题 I renamed my UsersController.php file to ~UsersController.php for testing purposes and everything was working fine until I renamed it back to UsersController.php and now I'm getting the below error include(C:\xampp\htdocs\xxx\vendor\composer/../../app/Http/Controllers/~UsersController.php): failed to open stream: No such file or directory i'm getting the above error when I want submit form to UsersController while I didn't change anything in my route file or views. 回答1: Try php artisan config

How to put Content object (in Controller) inside another object to be returned

别等时光非礼了梦想. 提交于 2020-03-05 04:47:10
问题 I have the following code that returns a List in CVS format using Content , which is working fine. public ContentResult LearningActionMonitoringPageDataAsync(int actionId) { //other code using (var stream = new MemoryStream()) using (var reader = new StreamReader(stream)) using (var writer = new StreamWriter(stream)) using (var csv = new CsvWriter(writer)) { csv.WriteRecords(resultsToReturn); writer.Flush(); stream.Position = 0; text = reader.ReadToEnd(); } return Content(text, "text/csv"); }

CodeIgniter: How to set a controller function to be a post route?

蹲街弑〆低调 提交于 2020-02-08 07:22:03
问题 I usually use something like: class User extends CI_Controller { public function save() { if($this->input->is_post()) { //my own method ...... } } } Is there any other way, eg. in Slim framework: post("/user/save", function() { ...... }); or in .Net MVC: [HttpPost] public ActionResult save(User model) { ...... } Or can CodeIgniter handle this in its route config file? Thanks for answer. 回答1: Codeigniter has no built-in support for REST. If you want it, you need to use third-party library or

Transparent stage/scene loses its transparency after loading another FXML file

亡梦爱人 提交于 2020-02-07 15:45:12
问题 When I start my application my transparent javafx.stage.Stage shows a half transparent image as expected. But after a second stage is loaded the first stage loses its transparency. The weird thing is that if the second fxml file ("MainScreen.fxml") doesn't contains any components like buttons or text fields, the background stays transparent. I'm using JavaFX with JavaSE-1.8 in eclipse neon.2 on macOS Sierra. Main class package customPackage.main; import javafx.animation.FadeTransition; import

ASP.NET Controller Base Class User.Identity.Name

浪尽此生 提交于 2020-01-31 18:16:28
问题 As described in this post, I created an abstract base controller class in order to be able to pass data from a controller to master.page. In this case, I want to lookup a user in my db, querying for User.Identity.Name (only if he is logged in). However, I noticed that in this abstract base class the User property is always null . What do I have to do to get this working? Thanks a lot 回答1: As Paco suggested, the viewdata isn't initialized till after you are trying to use it. Try overriding