com.Accenture.Learnercontroller.java Source code

Java tutorial

Introduction

Here is the source code for com.Accenture.Learnercontroller.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.Accenture;

import java.io.IOException;
import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author coldday
 */
@Controller
public class Learnercontroller {
    ApplicationContext r = new ClassPathXmlApplicationContext("../../WEB-INF/applicationContext.xml");
    learnerDao dao = (learnerDao) r.getBean("d");

    @RequestMapping("/hello")
    public ModelAndView helloWorld() {
        String message = "HELLO SPRING NSIZWA ";
        return new ModelAndView("hello", "message", message);
    }

    @RequestMapping("/view")
    public ModelAndView view(ModelAndView model) throws IOException {
        List<learnerspojo> view = dao.getLearners();
        model.addObject("msg", view);
        return model;
    }

}