Linux查看端口占用情况

查看80端口的占用情况:lsof -i:80 或者 netstat -apn | grep 80

VMware中Ubuntu静态IP设置方法

首先确认下VMware中相关网络的设置情况:

Ubuntu更换阿里源方法

Ubuntu更换阿里源方法小结:

Ubuntu下安装ssh服务

判断是否已经安装ssh服务:

反向代理服务器的工作原理

(一)概述

反向代理(Reverse Proxy)方式是指以代理服务器来接受Internet上的连接请求,然后将请求转发给内部网络上的服务器;并将从服务器上得到的结果返回给Internet上请求连接的客户端,此时代理服务器对外就表现为一个服务器。

MyBatis使用properties配置及类别名使用

(一)将连接数据库的配置单独放在一个properties文件中

可以直接将数据库的连接配置信息写在MyBatis的conf.xml文件中,如下:

MyBatis实现关联表查询

(一)一对一关联

1.1 提出需求

根据班级id查询班级信息(带老师信息)

Spring MVC @ModelAttribute Annotation Example

In this page we will learn how to use @ModelAttribute annotation in our spring MVC application. @ModelAttribute binds method parameter or the method response to a named model attribute. @ModelAttribute has an element as value. @ModelAttribute can be used at method level as well as parameter level. The use of @ModelAttribute at parameter level is to accept the value of form from the web request. The one use of @ModelAttribute at method level is assigning values to Model as default. This method will be created in the class annotated with @ModelAttribute. Here we will discuss both approach with example.

Spring MVC Exception Handling and Global Exception Example

Spring provides a robust exception handling framework. We can handle exceptions using @ResponseStatus, @ExceptionHandler, HandlerExceptionResolver and @ControllerAdvice. @ResponseStatus defines a status code for the given exception and can be used at custom exception class level and method level with @ExceptionHandler in controller. In controller class, we can define handler method using @ExceptionHandler and this will be controller specific. To handle exception globally, spring provides @ControllerAdvice that will be available for every controller. Define a class for global exception and annotate it with @ControllerAdvice and we need to define methods using @ExceptionHandler annotation within the class. Spring provides one more approach to handle exception. Use HandlerExceptionResolver in spring XML or java configuration where we can define mappings of exception type and view name. Find the complete example with description.

Spring MVC @ControllerAdvice Annotation Example

@ControllerAdvice annotation is a specialization of @Component. The classes annotated with @ControllerAdvice are auto detected by classpath scanning. The use of @ControllerAdvice is advising all or selected controllers for @ExceptionHandler, @InitBinder and @ModelAttribute. What we have to do is create a class annotated with @ControllerAdvice and create required method which will be annotated with @ExceptionHandler for global exception handling, @InitBinder for global init binding and @ModelAttribute for global model attributes addition. Whenever a request comes to controller and its method with @RequestMapping and if there is no locally defined @ExceptionHandler, @InitBinder and @ModelAttribute, the globally defined class annotated with @ControllerAdvice is served.