Upload and download
12. Upload and download
File upload is one of the most common functions in project development. Spring MVC can well support file upload, but MultipartResolver is not installed in the context of spring MVC by default, so it cannot handle file upload by default. If you want to use spring's file upload function, you need to configure MultipartReso ...
Added by velkymx on Thu, 10 Mar 2022 13:53:39 +0200
Jump mode and data processing
6. Jump mode
6.1 forwarding and redirection via spring MVC - no view parser required
Before testing, you need to comment out the view parser
@Controller
public class ResultSpringMVC {
@RequestMapping("/rsm/t1")
public String test1(){
//forward
return "/index.jsp";
}
@RequestMapping("/rsm/t2")
public String test2(){
...
Added by smileyriley21 on Wed, 09 Mar 2022 04:43:17 +0200
Controller and RestFul
5. Controller and RestFul
5.1 controller
The complex controller provides the behavior of accessing the application program, which is usually realized by interface definition or annotation definition.
The controller is responsible for parsing the user's request and transforming it into a model.
In Spring MVC, a controller class can contain mult ...
Added by poring on Wed, 09 Mar 2022 03:12:52 +0200
Spring MVC interceptor and exception handling
Interceptor
Interceptor configuration
Interceptors in spring MVC are used to intercept the execution of controller methods.
Interceptors in spring MVC need to implement HandlerInterceptor.
package com.atguigu.springmvc.interceptor;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAn ...
Added by mancroft on Sat, 05 Mar 2022 04:19:59 +0200
Spring MVC -- using Controller to return JSON data
Spring MVC -- using Controller to return JSON data
1. Use Jackson
Jackson: at present, the famous json parsing tool class library
Dependencies imported using Jackson:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
...
Added by khefner on Fri, 04 Mar 2022 19:08:48 +0200
Spring MVC requests and responses
Spring MVC requests and responses
1, Response of spring MVC
The data response methods of spring MVC are as follows:
Page Jump
Return string directlyReturn via ModelAndView object Write back data
Return string directlyReturns an object or collection
1. Page Jump
1.1. Directly return string
In the code for getting ...
Added by robin339 on Fri, 04 Mar 2022 15:45:35 +0200
Recommend learning java -- the first lesson of spring MVC
Spring MVC overview
Spring MVC is a module in the spring framework and one of the cores of spring. It is often used for web development. Its bottom layer is Servlet, so it is also called Spring web mvc. Because the internal architecture pattern is mvc architecture, it is called Spring MVC
Spring MVC is a container that manages the controlle ...
Added by Rother2005 on Fri, 04 Mar 2022 13:06:25 +0200
Spring MVC realizes file upload and download
File upload is one of the most common functions in project development. Spring MVC can well support file upload, but MultipartResolver is not installed in the context of spring MVC by default, so it cannot handle file upload by default. If you want to use spring's file upload function, you need to configure MultipartResolver in the context.
Fr ...
Added by eflopez on Fri, 25 Feb 2022 18:59:23 +0200
Study notes of spring MVC
Introduction to spring MVC
Official documents: https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc
First try spring MVC
Three major components that must be configured to use spring MVC:
Process mapper, process adapter, view parser
schematic diagram
Operation steps
Import Java Web and Spring dependenc ...
Added by simona_85 on Fri, 25 Feb 2022 18:58:30 +0200
Common annotations of spring MVC
1.@RequestParam
1. It is used to receive the parameters passed by the method before the parameters passed by the method (it is an annotation that accepts common parameters in spring MVC)
2. Attribute: name in value request parameter
required: whether this parameter is provided in the reques ...
Added by Sgt.Angel on Fri, 25 Feb 2022 14:21:11 +0200