CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-springframework--spring-web

Spring Web module providing web application infrastructure including HTTP integration, servlet filters, Spring web MVC framework, and reactive web stack support

Overview
Eval results
Files

index.mddocs/

Spring Web Module

Spring Web module provides foundational web infrastructure including HTTP abstractions, web client capabilities, servlet integration, reactive web support, and web-related utilities. It serves as the foundation for both Spring MVC (servlet-based) and Spring WebFlux (reactive) web frameworks.

Package Information

  • Package Name: spring-web
  • Group ID: org.springframework
  • Artifact ID: spring-web
  • Package Type: Maven
  • Language: Java
  • Version: 6.2.8
  • Installation:
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>6.2.8</version>
    </dependency>

Core Imports

// HTTP abstractions
import org.springframework.http.*;
import org.springframework.http.client.*;

// Web clients
import org.springframework.web.client.RestTemplate;
import org.springframework.web.client.RestClient;

// Message conversion
import org.springframework.http.converter.*;
import org.springframework.http.codec.*;

// Web binding and annotations
import org.springframework.web.bind.annotation.*;

// Reactive web support
import org.springframework.web.server.*;
import org.springframework.web.reactive.function.client.*;

// Web utilities
import org.springframework.web.util.*;

Basic Usage

import org.springframework.web.client.RestTemplate;
import org.springframework.http.*;

// Create a REST client
RestTemplate restTemplate = new RestTemplate();

// Simple GET request
String result = restTemplate.getForObject(
    "https://api.example.com/users/{id}", 
    String.class, 
    123
);

// POST request with body
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<User> request = new HttpEntity<>(user, headers);

ResponseEntity<User> response = restTemplate.postForEntity(
    "https://api.example.com/users",
    request,
    User.class
);

// Modern fluent API with RestClient
RestClient restClient = RestClient.create();
User user = restClient.get()
    .uri("https://api.example.com/users/{id}", 123)
    .retrieve()
    .body(User.class);

Architecture

The Spring Web module is organized around several key architectural components:

  • HTTP Abstractions: Core HTTP types (HttpEntity, ResponseEntity, HttpHeaders) for building web applications
  • Client Infrastructure: HTTP client factories and request/response abstractions for outbound communication
  • Message Processing: Converters and codecs for transforming between Java objects and HTTP message bodies
  • Web Binding: Annotation-driven parameter binding and data validation for web endpoints
  • Reactive Support: Non-blocking web server infrastructure for reactive applications
  • Integration Layer: Servlet API integration and web context management

Capabilities

HTTP Abstractions and Core Types

Essential HTTP types for building request/response entities, working with headers, status codes, and media types.

// Core HTTP entity types
class HttpEntity<T> {
    HttpEntity(T body);
    HttpEntity(MultiValueMap<String, String> headers);
    HttpEntity(T body, MultiValueMap<String, String> headers);
    HttpHeaders getHeaders();
    T getBody();
    boolean hasBody();
}

class ResponseEntity<T> extends HttpEntity<T> {
    ResponseEntity(HttpStatusCode status);
    ResponseEntity(T body, HttpStatusCode status);
    HttpStatusCode getStatusCode();
    static ResponseEntity<T> ok(T body);
    static ResponseEntity<Void> noContent();
}

class RequestEntity<T> extends HttpEntity<T> {
    RequestEntity(HttpMethod method, URI url);
    RequestEntity(T body, HttpMethod method, URI url);
    HttpMethod getMethod();
    URI getUrl();
}

HTTP Abstractions

HTTP Client Infrastructure

Comprehensive HTTP client support including RestTemplate, modern RestClient, and client infrastructure.

// Modern fluent client API
interface RestClient {
    RequestHeadersUriSpec<?> get();
    RequestBodyUriSpec post();
    RequestBodyUriSpec put();
    static RestClient create();
    static RestClient create(String baseUrl);
}

// Traditional template-based client
class RestTemplate implements RestOperations {
    RestTemplate();
    <T> T getForObject(String url, Class<T> responseType, Object... uriVariables);
    <T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Object... uriVariables);
    <T> T postForObject(String url, Object request, Class<T> responseType, Object... uriVariables);
}

HTTP Clients

Message Conversion and Encoding

HTTP message converters for servlet applications and reactive codecs for streaming applications.

// Message converter interface
interface HttpMessageConverter<T> {
    boolean canRead(Class<?> clazz, MediaType mediaType);
    boolean canWrite(Class<?> clazz, MediaType mediaType);
    List<MediaType> getSupportedMediaTypes();
    T read(Class<? extends T> clazz, HttpInputMessage inputMessage);
    void write(T t, MediaType contentType, HttpOutputMessage outputMessage);
}

// Reactive message reader/writer
interface HttpMessageReader<T> {
    boolean canRead(ResolvableType elementType, MediaType mediaType);
    Flux<T> read(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints);
    Mono<T> readMono(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints);
}

Message Conversion

Web Binding and Annotations

Annotation-driven web development with parameter binding, validation, and controller configuration.

// Core web annotations
@RequestMapping(value = "/api/users", method = RequestMethod.GET)
@GetMapping("/api/users/{id}")
@PostMapping("/api/users")
@RequestParam(value = "name", required = false, defaultValue = "unknown")
@PathVariable("id")
@RequestBody
@ResponseBody

// Controller configuration
@RestController
@ControllerAdvice
@ExceptionHandler(value = UserNotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)

Web Binding and Annotations

Reactive Web Support

Non-blocking web server infrastructure for building reactive applications with WebFlux.

// Core reactive web interfaces
interface WebHandler {
    Mono<Void> handle(ServerWebExchange exchange);
}

interface ServerWebExchange {
    ServerHttpRequest getRequest();
    ServerHttpResponse getResponse();
    Map<String, Object> getAttributes();
    Mono<WebSession> getSession();
    Principal getPrincipal();
}

// WebFilter for reactive request processing
interface WebFilter {
    Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain);
}

Reactive Web Support

Web Utilities and Additional Features

URI building, HTML escaping, pattern matching, CORS support, and other web utilities.

// URI building utilities
class UriComponentsBuilder implements UriBuilder {
    static UriComponentsBuilder fromPath(String path);
    static UriComponentsBuilder fromUri(URI uri);
    UriComponentsBuilder path(String path);
    UriComponentsBuilder queryParam(String name, Object... values);
    URI build(Object... uriVariables);
}

// Web service client support
class HttpServiceProxyFactory {
    static HttpServiceProxyFactory.Builder builder();
    <S> S createClient(Class<S> serviceType);
}

Web Utilities

Common Types

// HTTP method enumeration
enum HttpMethod {
    GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
    boolean matches(String method);
    static HttpMethod resolve(String method);
}

// HTTP status codes
enum HttpStatus implements HttpStatusCode {
    OK(200), CREATED(201), NO_CONTENT(204),
    BAD_REQUEST(400), UNAUTHORIZED(401), NOT_FOUND(404),
    INTERNAL_SERVER_ERROR(500);
    
    int value();
    String getReasonPhrase();
    boolean is2xxSuccessful();
    boolean is4xxClientError();
    static HttpStatus valueOf(int statusCode);
}

// Media type representation
class MediaType extends MimeType {
    static final MediaType APPLICATION_JSON;
    static final MediaType APPLICATION_XML;
    static final MediaType TEXT_PLAIN;
    static final MediaType MULTIPART_FORM_DATA;
    
    MediaType(String type, String subtype);
    boolean includes(MediaType other);
    static MediaType parseMediaType(String mediaType);
}

// HTTP headers management
class HttpHeaders implements MultiValueMap<String, String> {
    HttpHeaders();
    void setAccept(List<MediaType> acceptableMediaTypes);
    void setContentType(MediaType mediaType);
    void setContentLength(long contentLength);
    MediaType getContentType();
    long getContentLength();
}

Install with Tessl CLI

npx tessl i tessl/maven-org-springframework--spring-web

docs

http-abstractions.md

http-clients.md

index.md

message-conversion.md

reactive-web.md

web-binding.md

web-utilities.md

tile.json