انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهJNR-013-L02

الـ Controllers: حافة HTTP

  • الدرس 2 من 8
  • Junior
في هذا الدرس 4 موضوعات

هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

في هذا الدرس

write a thin controller.

الموضوعات المخطط لها

  • A controller translates HTTP to a method call and the result back to HTTP.
  • It handles paths, methods, status codes, and request/response bodies.
  • It contains no business rules and no database code.
  • @RestController returns data (JSON), not pages.
تفاصيل المخطط المبدئي

عرض عملي

java
@RestController
@RequestMapping("/products")
class ProductController {
    private final ProductService service;
    ProductController(ProductService service) { this.service = service; }

    @GetMapping("/{id}")
    ProductResponse get(@PathVariable long id) { return service.get(id); }
}

اختبر فهمك

Where does "a discount cannot exceed 50%" go?

أظهر الإجابة

In the service, not the controller.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.