0% found this document useful (0 votes)
10 views

SpringBoot MVC

Uploaded by

Dhanashree G
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

SpringBoot MVC

Uploaded by

Dhanashree G
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Welcome to Print the contents of list along with the subList.

My first Spring MVC Application(30 min)

3.1 File Name: ContentController.java

package com.example.demo.content;

import java.util.List;

import org.springframework.web.bind.annotation.RestController;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

@RestController

public class ContentController {

//Put your code here.

@Autowired

private ContentService NB;

@RequestMapping("/")

public List<Category> getContentList(){

List<Category> nb = NB.getAllContent();

return nb;

3.2 File Name: ContentService.java

package com.example.demo.content;

import java.util.Arrays;

import java.util.List;

import java.util.ArrayList;
import org.springframework.stereotype.Service;
@Service

public class ContentService {

public List<Category> NBcategories = new ArrayList<>();


//put your code here.

public List<Category> getAllContent() {

List<Course> NBcourse = new ArrayList<>();

NBcourse.add(new Course(1,"NotesBureau",200,200,1001));

NBcourse.add(new Course(1,"NotesBureau",200,200,1001));

NBcourse.add(new Course(1,"NotesBureau",200,200,1001));

List<Category> NBategories = new ArrayList<>();

NBategories.add(new Category(1001,"NotesBureau","Lets teach and learn",NBcourse));


NBategories.add(new Category(1001,"NotesBureau","Lets teach and learn",NBcourse));

NBategories.add(new Category(1001,"NotesBureau","Lets teach and learn",NBcourse));

return NBategories;

You might also like