Skip to content

Instantly share code, notes, and snippets.

@jeevan-patil
Created May 17, 2013 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeevan-patil/5597331 to your computer and use it in GitHub Desktop.
Save jeevan-patil/5597331 to your computer and use it in GitHub Desktop.
Sample spring controller using annotations.
package com.transbank.online.controller.customer;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.transbank.online.bean.Customer;
import com.transbank.online.service.iface.CustomerService;
@Controller
public class CustomerController {
private CustomerService customerService;
@Value("${my.id}")
private String myId;
/**
* adding customer
*
* @return
*/
@RequestMapping(value = "customer/add", method = RequestMethod.GET)
public String addCustomer() {
return "customer/add";
}
/**
* view customer info
*
* @return
*/
@RequestMapping(value = "customer/view", method = RequestMethod.GET)
public String viewCustomer(Model model) {
Customer cust = customerService.getCustomerById(myId);
model.addAttribute("customerList", cust);
return "customer/view";
}
@Autowired
@Qualifier("customerService")
public void setCustomerService(CustomerService customerService) {
this.customerService = customerService;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment