Java tutorial
/* * * Springcome.me, Software License, Version 1.0 * * Copyright (c) 2012-2013 Springcome.me, * All rights reserved. * * DON'T COPY OR REDISTRIBUTE THIS SOURCE CODE WITHOUT PERMISSION. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Springcome.me OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * For more information on this product, please see * http://www.springcome.me * */ package com.springcome.exam; import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; import com.springcome.common.base.BaseController; import com.springcome.exam.entity.Stock; /** * Exam Class?. * * @author KYUNG-IL, KIM(fun.deviation@gmail.com) * @version 2.0 * @since 2014. 3. 19 */ @Controller @RequestMapping("/exam") public class ExamController extends BaseController { /** The service. */ @Autowired private IExamService service; /** * Inits the controller. * * @return the string */ @RequestMapping(method = RequestMethod.GET, value = "/test") public String initController() { List<Stock> list = service.selectSotckList(); for (Stock stock : list) { System.out.println( "### " + stock.getStockId() + " : " + stock.getStockCode() + " : " + stock.getStockName()); } return "exam/exam"; } @RequestMapping(method = RequestMethod.GET, value = "/pk") public ModelAndView selectExamPk(String id) { logger.info("### " + id); Stock stock = service.selectStockPk(Long.parseLong(id)); logger.info("### " + stock.getStockName() + " : " + stock.getStockCode()); ModelAndView mv = new ModelAndView("exam/exam"); mv.addObject("stock", stock); return mv; } /** * stock ? . * * @return the string */ @RequestMapping(method = RequestMethod.GET, value = "/insert") public String insertStock() { List<Stock> list = new ArrayList<Stock>(); for (int i = 0; i < 5; i++) { Stock stock = new Stock(); stock.setStockCode("Code" + i); stock.setStockName("Name" + i); list.add(stock); } service.insertStock(list); return "exam/exam"; } }