shiotsugou / framework_2c

0 stars 0 forks source link

10月24日授業内容まとめ #3

Open shiotsugou opened 2 years ago

shiotsugou commented 2 years ago

package MyshopController.controller;

import java.util.List; import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod;

@controller public class MyshopController {

@Autowired JdbcTemplate jdbcTemplate;

@RequestMapping(path = "/myshop", method = RequestMethod.GET) public String viewMyShop() { return "index"; }

@RequestMapping(path = "/about", method = RequestMethod.GET) public String viewAbout() { return "about"; }

@RequestMapping(path = "/shop", method = RequestMethod.GET) public String viewShop(Model model) { //itemテーブルにSELECT文を発行する。 List<Map<String, Object>> list; list = jdbcTemplate.queryForList("SELECT * FROM item;");

model.addAttribute("itemList", list);

return "shop";

}

@RequestMapping(path = "/contact", method = RequestMethod.GET) public String viewContact() { return "contact"; } }

shiotsugou commented 2 years ago
Zay Shop - Product Listing Page

Our Brands

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod Lorem ipsum dolor sit amet.