spring-web
/spring-web
Wspiera Spring Web MVC w Spring Boot 3.x: RestClient, WebClient, ResponseEntity, interceptory, negocjacja treści, przesyłanie plików, odpowiedzi strumieniowe i własne resolvery argumentów.
- Autor
- claude-dev-suite ↗
- Repozytorium
- claude-dev-suite ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 21.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 5
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 4
Brak sygnałów. Repozytorium zmienione 21.10.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Wspiera Spring Web MVC w Spring Boot 3.x: RestClient, WebClient, ResponseEntity, interceptory, negocjacja treści, przesyłanie plików, odpowiedzi strumieniowe i własne resolvery argumentów.
Wyzwalacze z opisu
Oryginalny opis (EN)
Spring Web MVC advanced for Spring Boot 3.x. Covers RestClient (Spring 6.1+), WebClient, ResponseEntity patterns, interceptors, content negotiation, file upload/download, streaming responses, and custom argument resolvers. USE WHEN: user mentions "spring web", "RestClient", "WebClient", "ResponseEntity", "HTTP client Spring", "file upload", "file download", "streaming response", "HandlerInterceptor", "content negotiation", "argument resolver" DO NOT USE FOR: reactive web stack - use `spring-webflux` skill, REST controller basics - use `spring-rest` skill, WebSocket - use `spring-websocket` ski
Jak działa
- Quick Start
- RestClient Essentials (Spring 6.1+)
- ResponseEntity Quick Patterns
- File Upload/Download Quick Start
- Interceptors Quick Start
- Best Practices
- When NOT to Use This Skill
- Anti-Patterns
- Quick Troubleshooting
- Reference Files
Podgląd SKILL.md
---
name: spring-web
description: |
Spring Web MVC advanced for Spring Boot 3.x. Covers RestClient (Spring 6.1+),
WebClient, ResponseEntity patterns, interceptors, content negotiation,
file upload/download, streaming responses, and custom argument resolvers.
USE WHEN: user mentions "spring web", "RestClient", "WebClient", "ResponseEntity",
"HTTP client Spring", "file upload", "file download", "streaming response",
"HandlerInterceptor", "content negotiation", "argument resolver"
DO NOT USE FOR: reactive web stack - use `spring-webflux` skill,
REST controller basics - use `spring-rest` skill,
WebSocket - use `spring-websocket` skill
allowed-tools: Read, Grep, Glob, Write, Edit
---
# Spring Web MVC Advanced
> **Deep Knowledge**: Use `mcp__documentation__fetch_docs` with technology: `spring-web` for comprehensive documentation.
## Quick Start
```java
@RestController
@RequestMapping("/api/v1")
@RequiredArgsConstructor
public class ApiController {
private final RestClient restClient;
@GetMapping("/proxy/{id}")
public ResponseEntity<Resource> proxyRequest(@PathVariable Long id) {
return restClient.get()
.uri("/external/resource/{id}", id)
.retrieve()
.toEntity(Resource.class);
}
}
@Configuration
public class RestClientConfig {
@Bean
public RestClient restClient(RestClient.Builder builder) {
return builder
.baseUrl("https://api.external.com")
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.connectTimeout(Duration.ofSeconds(5))
.readTimeout(Duration.ofSeconds(30))
.build();
}
}
```
---
## RestClient Essentials (Spring 6.1+)
RestClient is the new synchronous HTTP client replacing RestTemplate.
```java
@Service
@RequiredArgsConstructor
public class UserApiClient {
private final RestClient restClient;
// GET
public UserDto getUser(Long id) {
return restClient.get()
.uri("/users/{id}", id)
.retrieve()
.body(UserDto.class);
}
// POST
public UserDto createUser(CreateUserRequest request) {
return restClient.post()
.uri("/users")
.body(request)
.retrieve()
.body(UserDto.class);
}
// With error handling
public UserDto getUserSafe(Long id) {
return restClient.get()
.uri("/users/{id}", id)
.retrieve()
.onStatus(HttpStatusCode::is4xxClientError, (req, res) -> {
throw new ResourceNotFoundException("User not found: " + id);
})
.body(UserDto.class);
}
}
```
> **Full Reference**: See [http-clients.md](http-clients.md) for complete RestClient and WebClient documentation.
---
## ResponseEntity Quick Patterns
```java
@RestController
@RequestMapping("/api/v1/users")
public class UserController {
// Created with Location
@PostMapping
public ResponseEntity<UserResponse> create(
@Valid @RequestBody CreateUserRequest req,
UriComponentsBuilder uriBuilder) {
UserResponse created = service.create(req);
URI location = uriBuilder.path("/api/v1/users/{id}")
.buildAndExpand(created.getId()).toUri();
return ResponseEntity.created(location).body(created);
}
// With ETag
@GetMapping("/{id}")
public ResponseEntity<UserResponse> get(@PathVariable Long id) {
UserResponse user = service.findById(id);
return ResponseEntity.ok()
.eTag("\"" + user.getVersion() + "\"")
.cacheControl(CacheControl.maxAge(60, TimeUnit.SECONDS))
.body(user);
}
// No Content
@DeleteMapping("/{id}")
public ResponseEntity<Void> delete(@PathVariable Long id) {
service.delete(id);
return ResponseEntity.noContent().build();
}
}
```
> **Full Reference**: See [patterns.md](patterns.md) for ResponseEntity, Content Negotiation, and Streaming.
---
## File Upload/Download Quick Start
```java
// Upload
@PostMapping("/upload")
public ResponseEntity<FileResponse> upload(@RequestParam("file") MultipartFile file) {
String fileName = storageService.store(file);
return ResponseEntity.ok(new FileResponse(fileName, file.getSize()));
}
// Download
@GetMapping("/download/{fileName}")
public ResponseEntity<Resource> download(@PathVariable String fileName) {
Resource resource = storageService.loadAsResource(fileName);
return ResponseEntity.ok()
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + fileName + "\"")
.body(resource);
}
```
> **Full Reference**: See [file-handling.md](file-handling.md) for complete file operations.
---
## Interceptors Quick Start
```java
@Slf4j
@Component
public class LoggingInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) {
MDC.put("requestId", UUID.randomUUID().toString());
request.setAttribute("startTime", System.currentTimeMillis());
log.info("==> {} {}", request.getMethod(), request.getRequestURI());
return true;
}
@Override
public void afterCompletion(HttpServletRequest request,
HttpServletResponse response,
Object handler, Exception ex) {
long duration = System.currentTimeMillis() -
(Long) request.getAttribute("startTime");
log.info("<== {} ({} ms)", response.getStatus(), duration);
MDC.clear();
}
}
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loggingInterceptor).addPathPatterns("/api/**");
}
}
```
> **Full Reference**: See [advanced.md](advanced.md) for Interceptors, Argument Resolvers, Exception Handling, and Testing.
---
## Best Practices
| Do | Don't |
|----|-------|
| Use RestClient for sync calls (Spring 3.2+) | Use deprecated RestTemplate |
| Configure explicit timeouts | Rely on default timeouts |
| Implement retry with exponential backoff | Retry immediately without delay |
| Use interceptors for centralized logging | Log in each method |
| Wrap responses in ResponseEntity | Return raw objects |
---
## When NOT to Use This Skill
- **Reactive applications** - Use `spring-webflux` skill
- **Basic REST controllers** - Use `spring-rest` skill
- **WebSocket communication** - Use `spring-websocket` skill
- **GraphQL APIs** - Use `spring-graphql` skill
---
## Anti-Patterns
| Anti-Pattern | Problem | Solution |
|--------------|---------|----------|
| Using RestTemplate | Deprecated, not type-safe | Use RestClient (sync) or WebClient (async) |
| No timeout configuration | Requests hang indefinitely | Configure connect/read timeout |
| Memory leak with streams | Stream not closed | Use try-with-resources |
| N+1 HTTP calls | Calls in loop | Use batch endpoints or parallel calls |
| Blocking in WebFlux | .block() in reactive stack | Keep chain reactive |
---
## Quick Troubleshooting
| Problem | Diagnostic | Fix |
|---------|------------|-----|
| Connection timeout | Check network/firewall | Configure proper timeout values |
| SSL handshake fails | Check certificates | Configure SSLContext properly |
| Response not mapped | Check Content-Type | Configure message converters |
| Interceptor not called | Check registration | Verify interceptor order |
| File upload fails | Check size limits | Configure multipart settings |
---
## Reference Files
| File | Content |
|------|---------|
| [http-clients.md](http-clients.md) | RestClient, WebClient, Interceptors |
| [patterns.md](patterns.md) | ResponseEntity, Content Negotiation, Streaming |
| [file-handling.md](file-handling.md) | File Upload, Download, Storage Service |
| [advanced.md](advanced.md) | Argument Resolvers, HandlerInterceptors, Exception Handling, Testing |
---
## External Documentation
- [Spring Web MVC](https://docs.spring.io/spring-framework/reference/web/webmvc.html)
- [RestClient](https://docs.spring.io/spring-framework/reference/integration/rest-clients.html#rest-restclient)
- [WebClient](https://docs.spring.io/spring-framework/reference/web/webflux-webclient.html)
Pliki w paczce (5)
- SKILL.md 8 KB
- advanced.md 10 KB
- file-handling.md 7 KB
- http-clients.md 10 KB
- patterns.md 8 KB
Wersje
W bazie nie ma innych skilli o nazwie spring-web.
Migawka bazy z 13.11.2026 · wersja paczki bc21159c02df (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100spring-rest
Podaje wzorce kontrolerów REST w Spring: ResponseEntity, obsługa wyjątków, walidacja, HATEOAS, negocjacja treści i kontrolery asynchroniczne. - 100spring-webflux
Wspiera programowanie reaktywne w Spring WebFlux (Spring Boot 3.x): Mono i Flux, operatory, WebClient, endpointy funkcyjne, R2DBC, obsługa błędów i testy z StepVerifier. - 100http-interface-clients
Pomaga wywoływać zewnętrzne API ze Spring Boot 4 i Spring Framework 7 przez deklaratywne interfejsy HttpExchange: ImportHttpServices, grupowane adresy bazowe i timeouty oraz wybór między RestClient a WebClient. - 100http-interface-clients
Pomaga wywoływać zewnętrzne API ze Spring Boot 3 i Spring Framework 6 przez deklaratywne interfejsy HttpExchange: ręczna rejestracja proxy, RestClient lub WebClient oraz timeouty i obsługa błędów. - 95backend-spring-web
Przegląda kontrolery Spring MVC i WebFlux: wzorce RestController, wstrzykiwanie zależności, walidację @Valid i obsługę wyjątków. - 90spring-boot
Pomaga zmieniać aplikacje Java oparte na Spring Boot: MVC, Spring Security, Spring Data i konfigurację zarządzaną przez Spring.