Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.58 KB | None | 0 0
  1. ★ BCommand.java
  2.  
  3. package com.javalec.spring_16_1_ex1_srpingex.command;
  4.  
  5. import org.springframework.ui.Model;
  6.  
  7. public interface BCommand {
  8.  
  9. void execute(Model model);
  10.  
  11. }
  12.  
  13. ★BContentCommand.java
  14.  
  15. package com.javalec.spring_16_1_ex1_srpingex.command;
  16.  
  17. import java.util.Map;
  18.  
  19. import javax.servlet.http.HttpServletRequest;
  20.  
  21. import org.springframework.ui.Model;
  22.  
  23. import com.javalec.spring_16_1_ex1_srpingex.dao.BDao;
  24. import com.javalec.spring_16_1_ex1_srpingex.dto.BDto;
  25.  
  26. public class BContentCommand implements BCommand {
  27.  
  28. @Override
  29. public void execute(Model model) {
  30. // TODO Auto-generated method stub
  31.  
  32. Map<String, Object> map = model.asMap();
  33. HttpServletRequest request = (HttpServletRequest) map.get("request");
  34. String bId = request.getParameter("bId");
  35.  
  36. BDao dao = new BDao();
  37. BDto dto = dao.contentView(bId);
  38.  
  39. model.addAttribute("content_view", dto);
  40.  
  41. }
  42.  
  43. }
  44.  
  45.  
  46. ★ web.xml
  47.  
  48. <?xml version="1.0" encoding="UTF-8"?>
  49. <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
  50. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  51. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  52.  
  53. <!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
  54. <context-param>
  55. <param-name>contextConfigLocation</param-name>
  56. <param-value>/WEB-INF/spring/root-context.xml</param-value>
  57. </context-param>
  58.  
  59. <!-- Creates the Spring Container shared by all Servlets and Filters -->
  60. <listener>
  61. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  62. </listener>
  63.  
  64. <!-- Processes application requests -->
  65. <servlet>
  66. <servlet-name>appServlet</servlet-name>
  67. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  68. <init-param>
  69. <param-name>contextConfigLocation</param-name>
  70. <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
  71. </init-param>
  72. <load-on-startup>1</load-on-startup>
  73. </servlet>
  74.  
  75. <servlet-mapping>
  76. <servlet-name>appServlet</servlet-name>
  77. <url-pattern>/</url-pattern>
  78. </servlet-mapping>
  79.  
  80. <filter>
  81. <filter-name>encodingFilter</filter-name>
  82. <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
  83.  
  84. <init-param>
  85. <param-name>encoding</param-name>
  86. <param-value>UTF-8</param-value>
  87. </init-param>
  88. </filter>
  89.  
  90. <filter-mapping>
  91. <filter-name>encodingFilter</filter-name>
  92. <url-pattern>/*</url-pattern>
  93. </filter-mapping>
  94.  
  95. </web-app>
  96.  
  97.  
  98. ★ servlet-context.xml
  99.  
  100. <?xml version="1.0" encoding="UTF-8"?>
  101. <beans:beans xmlns="http://www.springframework.org/schema/mvc"
  102. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  103. xmlns:beans="http://www.springframework.org/schema/beans"
  104. xmlns:context="http://www.springframework.org/schema/context"
  105. xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
  106. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  107. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
  108.  
  109. <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
  110.  
  111. <!-- Enables the Spring MVC @Controller programming model -->
  112. <annotation-driven />
  113.  
  114. <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
  115. <resources mapping="/resources/**" location="/resources/" />
  116.  
  117. <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
  118. <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  119. <beans:property name="prefix" value="/WEB-INF/views/" />
  120. <beans:property name="suffix" value=".jsp" />
  121. </beans:bean>
  122.  
  123. <context:component-scan base-package="com.javalec.spring_16_1_ex1_srpingex" />
  124.  
  125. </beans:beans>
  126.  
  127. ★ BController.java
  128.  
  129. package com.javalec.spring_16_1_ex1_srpingex.controller;
  130.  
  131. import javax.servlet.http.HttpServletRequest;
  132.  
  133. import org.springframework.stereotype.Controller;
  134. import org.springframework.ui.Model;
  135. import org.springframework.web.bind.annotation.RequestMapping;
  136. import org.springframework.web.bind.annotation.RequestMethod;
  137.  
  138. import com.javalec.spring_16_1_ex1_srpingex.command.BCommand;
  139. import com.javalec.spring_16_1_ex1_srpingex.command.BContentCommand;
  140. import com.javalec.spring_16_1_ex1_srpingex.command.BDeleteCommand;
  141. import com.javalec.spring_16_1_ex1_srpingex.command.BListCommand;
  142. import com.javalec.spring_16_1_ex1_srpingex.command.BModifyCommand;
  143. import com.javalec.spring_16_1_ex1_srpingex.command.BReplyCommand;
  144. import com.javalec.spring_16_1_ex1_srpingex.command.BReplyViewCommand;
  145. import com.javalec.spring_16_1_ex1_srpingex.command.BWriteCommand;
  146.  
  147. /**
  148. * Servlet implementation class BoardFrontController
  149. */
  150.  
  151. @Controller
  152. public class BController {
  153.  
  154. BCommand command = null;
  155.  
  156. @RequestMapping("/list")
  157. public String list(Model model) {
  158. System.out.println("list()");
  159. command = new BListCommand();
  160. command.execute(model);
  161.  
  162. return "list";
  163. }
  164.  
  165. @RequestMapping("/write_view")
  166. public String write_view(Model model) {
  167. System.out.println("write_view()");
  168.  
  169. return "write_view";
  170. }
  171.  
  172. @RequestMapping("/write")
  173. public String write(HttpServletRequest request, Model model) {
  174. System.out.println("write()");
  175.  
  176. model.addAttribute("request", request);
  177. command = new BWriteCommand();
  178. command.execute(model);
  179.  
  180. return "redirect:list";
  181. }
  182.  
  183. @RequestMapping("/content_view")
  184. public String content_view(HttpServletRequest request, Model model){
  185. System.out.println("content_view()");
  186.  
  187. model.addAttribute("request", request);
  188. command = new BContentCommand();
  189. command.execute(model);
  190.  
  191. return "content_view";
  192. }
  193.  
  194. @RequestMapping(value="/modify", method=RequestMethod.POST )
  195. public String modify(HttpServletRequest request, Model model){
  196. System.out.println("modify()");
  197.  
  198. model.addAttribute("request", request);
  199. command = new BModifyCommand();
  200. command.execute(model);
  201.  
  202. return "redirect:list";
  203. }
  204.  
  205. @RequestMapping("/reply_view")
  206. public String reply_view(HttpServletRequest request, Model model){
  207. System.out.println("reply_view()");
  208.  
  209. model.addAttribute("request", request);
  210. command = new BReplyViewCommand();
  211. command.execute(model);
  212.  
  213. return "reply_view";
  214. }
  215.  
  216. @RequestMapping("/reply")
  217. public String reply(HttpServletRequest request, Model model) {
  218. System.out.println("reply()");
  219.  
  220. model.addAttribute("request", request);
  221. command = new BReplyCommand();
  222. command.execute(model);
  223.  
  224. return "redirect:list";
  225. }
  226.  
  227. @RequestMapping("/delete")
  228. public String delete(HttpServletRequest request, Model model) {
  229. System.out.println("delete()");
  230.  
  231. model.addAttribute("request", request);
  232. command = new BDeleteCommand();
  233. command.execute(model);
  234.  
  235. return "redirect:list";
  236. }
  237.  
  238. }
  239.  
  240. ★ HomeController.java
  241. package com.javalec.spring_16_1_ex1_srpingex;
  242.  
  243. import java.text.DateFormat;
  244. import java.util.Date;
  245. import java.util.Locale;
  246.  
  247. import org.slf4j.Logger;
  248. import org.slf4j.LoggerFactory;
  249. import org.springframework.stereotype.Controller;
  250. import org.springframework.ui.Model;
  251. import org.springframework.web.bind.annotation.RequestMapping;
  252. import org.springframework.web.bind.annotation.RequestMethod;
  253.  
  254. /**
  255. * Handles requests for the application home page.
  256. */
  257. @Controller
  258. public class HomeController {
  259.  
  260. private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
  261.  
  262. /**
  263. * Simply selects the home view to render by returning its name.
  264. */
  265. @RequestMapping(value = "/", method = RequestMethod.GET)
  266. public String home(Locale locale, Model model) {
  267. logger.info("Welcome home! The client locale is {}.", locale);
  268.  
  269. Date date = new Date();
  270. DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
  271.  
  272. String formattedDate = dateFormat.format(date);
  273.  
  274. model.addAttribute("serverTime", formattedDate );
  275.  
  276. return "home";
  277. }
  278.  
  279. }
  280.  
  281.  
  282. ★ BDao.java
  283.  
  284. package com.javalec.spring_16_1_ex1_srpingex.dao;
  285.  
  286. import java.sql.Connection;
  287. import java.sql.PreparedStatement;
  288. import java.sql.ResultSet;
  289. import java.sql.Timestamp;
  290. import java.util.ArrayList;
  291.  
  292. import javax.naming.Context;
  293. import javax.naming.InitialContext;
  294. import javax.sql.DataSource;
  295.  
  296. import com.javalec.spring_16_1_ex1_srpingex.dto.BDto;
  297.  
  298.  
  299. public class BDao {
  300.  
  301. DataSource dataSource;
  302.  
  303. public BDao() {
  304. // TODO Auto-generated constructor stub
  305.  
  306. try {
  307. Context context = new InitialContext();
  308. dataSource = (DataSource) context.lookup("java:comp/env/jdbc/Oracle11g");
  309. } catch (Exception e) {
  310. // TODO: handle exception
  311. e.printStackTrace();
  312. }
  313. }
  314.  
  315. public void write(String bName, String bTitle, String bContent) {
  316. // TODO Auto-generated method stub
  317.  
  318. Connection connection = null;
  319. PreparedStatement preparedStatement = null;
  320.  
  321. try {
  322. connection = dataSource.getConnection();
  323. String query = "insert into mvc_board (bId, bName, bTitle, bContent, bHit, bGroup, bStep, bIndent) values (mvc_board_seq.nextval, ?, ?, ?, 0, mvc_board_seq.currval, 0, 0 )";
  324. preparedStatement = connection.prepareStatement(query);
  325. preparedStatement.setString(1, bName);
  326. preparedStatement.setString(2, bTitle);
  327. preparedStatement.setString(3, bContent);
  328. int rn = preparedStatement.executeUpdate();
  329. } catch (Exception e) {
  330. // TODO: handle exception
  331. e.printStackTrace();
  332. } finally {
  333. try {
  334. if(preparedStatement != null) preparedStatement.close();
  335. if(connection != null) connection.close();
  336. } catch (Exception e2) {
  337. // TODO: handle exception
  338. e2.printStackTrace();
  339. }
  340. }
  341.  
  342. }
  343.  
  344. public ArrayList<BDto> list() {
  345.  
  346. ArrayList<BDto> dtos = new ArrayList<BDto>();
  347. Connection connection = null;
  348. PreparedStatement preparedStatement = null;
  349. ResultSet resultSet = null;
  350.  
  351. try {
  352. connection = dataSource.getConnection();
  353.  
  354. String query = "select bId, bName, bTitle, bContent, bDate, bHit, bGroup, bStep, bIndent from mvc_board order by bGroup desc, bStep asc";
  355. preparedStatement = connection.prepareStatement(query);
  356. resultSet = preparedStatement.executeQuery();
  357.  
  358. while (resultSet.next()) {
  359. int bId = resultSet.getInt("bId");
  360. String bName = resultSet.getString("bName");
  361. String bTitle = resultSet.getString("bTitle");
  362. String bContent = resultSet.getString("bContent");
  363. Timestamp bDate = resultSet.getTimestamp("bDate");
  364. int bHit = resultSet.getInt("bHit");
  365. int bGroup = resultSet.getInt("bGroup");
  366. int bStep = resultSet.getInt("bStep");
  367. int bIndent = resultSet.getInt("bIndent");
  368.  
  369. BDto dto = new BDto(bId, bName, bTitle, bContent, bDate, bHit, bGroup, bStep, bIndent);
  370. dtos.add(dto);
  371. }
  372.  
  373. } catch (Exception e) {
  374. // TODO: handle exception
  375. e.printStackTrace();
  376. } finally {
  377. try {
  378. if(resultSet != null) resultSet.close();
  379. if(preparedStatement != null) preparedStatement.close();
  380. if(connection != null) connection.close();
  381. } catch (Exception e2) {
  382. // TODO: handle exception
  383. e2.printStackTrace();
  384. }
  385. }
  386. return dtos;
  387. }
  388.  
  389. public BDto contentView(String strID) {
  390. // TODO Auto-generated method stub
  391.  
  392. upHit(strID);
  393.  
  394. BDto dto = null;
  395. Connection connection = null;
  396. PreparedStatement preparedStatement = null;
  397. ResultSet resultSet = null;
  398.  
  399. try {
  400.  
  401. connection = dataSource.getConnection();
  402.  
  403. String query = "select * from mvc_board where bId = ?";
  404. preparedStatement = connection.prepareStatement(query);
  405. preparedStatement.setInt(1, Integer.parseInt(strID));
  406. resultSet = preparedStatement.executeQuery();
  407.  
  408. if(resultSet.next()) {
  409. int bId = resultSet.getInt("bId");
  410. String bName = resultSet.getString("bName");
  411. String bTitle = resultSet.getString("bTitle");
  412. String bContent = resultSet.getString("bContent");
  413. Timestamp bDate = resultSet.getTimestamp("bDate");
  414. int bHit = resultSet.getInt("bHit");
  415. int bGroup = resultSet.getInt("bGroup");
  416. int bStep = resultSet.getInt("bStep");
  417. int bIndent = resultSet.getInt("bIndent");
  418.  
  419. dto = new BDto(bId, bName, bTitle, bContent, bDate, bHit, bGroup, bStep, bIndent);
  420. }
  421.  
  422. } catch (Exception e) {
  423. // TODO: handle exception
  424. e.printStackTrace();
  425. } finally {
  426. try {
  427. if(resultSet != null) resultSet.close();
  428. if(preparedStatement != null) preparedStatement.close();
  429. if(connection != null) connection.close();
  430. } catch (Exception e2) {
  431. // TODO: handle exception
  432. e2.printStackTrace();
  433. }
  434. }
  435. return dto;
  436. }
  437.  
  438. public void modify(String bId, String bName, String bTitle, String bContent) {
  439. // TODO Auto-generated method stub
  440.  
  441. Connection connection = null;
  442. PreparedStatement preparedStatement = null;
  443.  
  444. try {
  445. connection = dataSource.getConnection();
  446.  
  447. String query = "update mvc_board set bName = ?, bTitle = ?, bContent = ? where bId = ?";
  448. preparedStatement = connection.prepareStatement(query);
  449. preparedStatement.setString(1, bName);
  450. preparedStatement.setString(2, bTitle);
  451. preparedStatement.setString(3, bContent);
  452. preparedStatement.setInt(4, Integer.parseInt(bId));
  453. int rn = preparedStatement.executeUpdate();
  454.  
  455. } catch (Exception e) {
  456. // TODO: handle exception
  457. e.printStackTrace();
  458. } finally {
  459. try {
  460. if(preparedStatement != null) preparedStatement.close();
  461. if(connection != null) connection.close();
  462. } catch (Exception e2) {
  463. // TODO: handle exception
  464. e2.printStackTrace();
  465. }
  466. }
  467. }
  468.  
  469. public void delete(String bId) {
  470. // TODO Auto-generated method stub
  471. Connection connection = null;
  472. PreparedStatement preparedStatement = null;
  473. try {
  474.  
  475. connection = dataSource.getConnection();
  476. String query = "delete from mvc_board where bId = ?";
  477. preparedStatement = connection.prepareStatement(query);
  478. preparedStatement.setInt(1, Integer.parseInt(bId));
  479. int rn = preparedStatement.executeUpdate();
  480.  
  481. } catch (Exception e) {
  482. // TODO: handle exception
  483. e.printStackTrace();
  484. } finally {
  485. try {
  486. if(preparedStatement != null) preparedStatement.close();
  487. if(connection != null) connection.close();
  488. } catch (Exception e2) {
  489. // TODO: handle exception
  490. e2.printStackTrace();
  491. }
  492. }
  493. }
  494.  
  495. public BDto reply_view(String str) {
  496. // TODO Auto-generated method stub
  497. BDto dto = null;
  498.  
  499. Connection connection = null;
  500. PreparedStatement preparedStatement = null;
  501. ResultSet resultSet = null;
  502. try {
  503.  
  504. connection = dataSource.getConnection();
  505. String query = "select * from mvc_board where bId = ?";
  506. preparedStatement = connection.prepareStatement(query);
  507. preparedStatement.setInt(1, Integer.parseInt(str));
  508. resultSet = preparedStatement.executeQuery();
  509.  
  510. if(resultSet.next()) {
  511. int bId = resultSet.getInt("bId");
  512. String bName = resultSet.getString("bName");
  513. String bTitle = resultSet.getString("bTitle");
  514. String bContent = resultSet.getString("bContent");
  515. Timestamp bDate = resultSet.getTimestamp("bDate");
  516. int bHit = resultSet.getInt("bHit");
  517. int bGroup = resultSet.getInt("bGroup");
  518. int bStep = resultSet.getInt("bStep");
  519. int bIndent = resultSet.getInt("bIndent");
  520.  
  521. dto = new BDto(bId, bName, bTitle, bContent, bDate, bHit, bGroup, bStep, bIndent);
  522. }
  523.  
  524. } catch (Exception e) {
  525. // TODO: handle exception
  526. e.printStackTrace();
  527. } finally {
  528. try {
  529. if(preparedStatement != null) preparedStatement.close();
  530. if(connection != null) connection.close();
  531. } catch (Exception e2) {
  532. // TODO: handle exception
  533. e2.printStackTrace();
  534. }
  535. }
  536.  
  537. return dto;
  538. }
  539.  
  540. public void reply(String bId, String bName, String bTitle, String bContent, String bGroup, String bStep, String bIndent) {
  541. // TODO Auto-generated method stub
  542.  
  543. replyShape(bGroup, bStep);
  544.  
  545. Connection connection = null;
  546. PreparedStatement preparedStatement = null;
  547.  
  548. try {
  549. connection = dataSource.getConnection();
  550. String query = "insert into mvc_board (bId, bName, bTitle, bContent, bGroup, bStep, bIndent) values (mvc_board_seq.nextval, ?, ?, ?, ?, ?, ?)";
  551. preparedStatement = connection.prepareStatement(query);
  552.  
  553. preparedStatement.setString(1, bName);
  554. preparedStatement.setString(2, bTitle);
  555. preparedStatement.setString(3, bContent);
  556. preparedStatement.setInt(4, Integer.parseInt(bGroup));
  557. preparedStatement.setInt(5, Integer.parseInt(bStep) + 1);
  558. preparedStatement.setInt(6, Integer.parseInt(bIndent) + 1);
  559.  
  560. int rn = preparedStatement.executeUpdate();
  561. } catch (Exception e) {
  562. // TODO: handle exception
  563. e.printStackTrace();
  564. } finally {
  565. try {
  566. if(preparedStatement != null) preparedStatement.close();
  567. if(connection != null) connection.close();
  568. } catch (Exception e2) {
  569. // TODO: handle exception
  570. e2.printStackTrace();
  571. }
  572. }
  573.  
  574. }
  575.  
  576. private void replyShape( String strGroup, String strStep) {
  577. // TODO Auto-generated method stub
  578. Connection connection = null;
  579. PreparedStatement preparedStatement = null;
  580.  
  581. try {
  582. connection = dataSource.getConnection();
  583. String query = "update mvc_board set bStep = bStep + 1 where bGroup = ? and bStep > ?";
  584. preparedStatement = connection.prepareStatement(query);
  585. preparedStatement.setInt(1, Integer.parseInt(strGroup));
  586. preparedStatement.setInt(2, Integer.parseInt(strStep));
  587.  
  588. int rn = preparedStatement.executeUpdate();
  589. } catch (Exception e) {
  590. // TODO: handle exception
  591. e.printStackTrace();
  592. } finally {
  593. try {
  594. if(preparedStatement != null) preparedStatement.close();
  595. if(connection != null) connection.close();
  596. } catch (Exception e2) {
  597. // TODO: handle exception
  598. e2.printStackTrace();
  599. }
  600. }
  601. }
  602.  
  603. private void upHit( String bId) {
  604. // TODO Auto-generated method stub
  605. Connection connection = null;
  606. PreparedStatement preparedStatement = null;
  607.  
  608. try {
  609. connection = dataSource.getConnection();
  610. String query = "update mvc_board set bHit = bHit + 1 where bId = ?";
  611. preparedStatement = connection.prepareStatement(query);
  612. preparedStatement.setString(1, bId);
  613.  
  614. int rn = preparedStatement.executeUpdate();
  615.  
  616. } catch (Exception e) {
  617. // TODO: handle exception
  618. e.printStackTrace();
  619. } finally {
  620. try {
  621. if(preparedStatement != null) preparedStatement.close();
  622. if(connection != null) connection.close();
  623. } catch (Exception e2) {
  624. // TODO: handle exception
  625. e2.printStackTrace();
  626. }
  627. }
  628. }
  629. }
  630.  
  631. ★ BDto.java
  632.  
  633. package com.javalec.spring_16_1_ex1_srpingex.dto;
  634.  
  635. import java.sql.Timestamp;
  636.  
  637. public class BDto {
  638.  
  639. int bId;
  640. String bName;
  641. String bTitle;
  642. String bContent;
  643. Timestamp bDate;
  644. int bHit;
  645. int bGroup;
  646. int bStep;
  647. int bIndent;
  648.  
  649. public BDto() {
  650. // TODO Auto-generated constructor stub
  651. }
  652.  
  653. public BDto(int bId, String bName, String bTitle, String bContent, Timestamp bDate, int bHit, int bGroup, int bStep, int bIndent) {
  654. // TODO Auto-generated constructor stub
  655. this.bId = bId;
  656. this.bName = bName;
  657. this.bTitle = bTitle;
  658. this.bContent = bContent;
  659. this.bDate = bDate;
  660. this.bHit = bHit;
  661. this.bGroup = bGroup;
  662. this.bStep = bStep;
  663. this.bIndent = bIndent;
  664. }
  665.  
  666. public int getbId() {
  667. return bId;
  668. }
  669.  
  670. public void setbId(int bId) {
  671. this.bId = bId;
  672. }
  673.  
  674. public String getbName() {
  675. return bName;
  676. }
  677.  
  678. public void setbName(String bName) {
  679. this.bName = bName;
  680. }
  681.  
  682. public String getbTitle() {
  683. return bTitle;
  684. }
  685.  
  686. public void setbTitle(String bTitle) {
  687. this.bTitle = bTitle;
  688. }
  689.  
  690. public String getbContent() {
  691. return bContent;
  692. }
  693.  
  694. public void setbContent(String bContent) {
  695. this.bContent = bContent;
  696. }
  697.  
  698. public Timestamp getbDate() {
  699. return bDate;
  700. }
  701.  
  702. public void setbDate(Timestamp bDate) {
  703. this.bDate = bDate;
  704. }
  705.  
  706. public int getbHit() {
  707. return bHit;
  708. }
  709.  
  710. public void setbHit(int bHit) {
  711. this.bHit = bHit;
  712. }
  713.  
  714. public int getbGroup() {
  715. return bGroup;
  716. }
  717.  
  718. public void setbGroup(int bGroup) {
  719. this.bGroup = bGroup;
  720. }
  721.  
  722. public int getbStep() {
  723. return bStep;
  724. }
  725.  
  726. public void setbStep(int bStep) {
  727. this.bStep = bStep;
  728. }
  729.  
  730. public int getbIndent() {
  731. return bIndent;
  732. }
  733.  
  734. public void setbIndent(int bIndent) {
  735. this.bIndent = bIndent;
  736. }
  737.  
  738. }
  739.  
  740. ★ log4j.xml
  741.  
  742. <?xml version="1.0" encoding="UTF-8"?>
  743. <!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
  744. <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
  745.  
  746. <!-- Appenders -->
  747. <appender name="console" class="org.apache.log4j.ConsoleAppender">
  748. <param name="Target" value="System.out" />
  749. <layout class="org.apache.log4j.PatternLayout">
  750. <param name="ConversionPattern" value="%-5p: %c - %m%n" />
  751. </layout>
  752. </appender>
  753.  
  754. <!-- Application Loggers -->
  755. <logger name="com.javalec.spring_16_1_ex1_srpingex">
  756. <level value="info" />
  757. </logger>
  758.  
  759. <!-- 3rdparty Loggers -->
  760. <logger name="org.springframework.core">
  761. <level value="info" />
  762. </logger>
  763.  
  764. <logger name="org.springframework.beans">
  765. <level value="info" />
  766. </logger>
  767.  
  768. <logger name="org.springframework.context">
  769. <level value="info" />
  770. </logger>
  771.  
  772. <logger name="org.springframework.web">
  773. <level value="info" />
  774. </logger>
  775.  
  776. <!-- Root Logger -->
  777. <root>
  778. <priority value="warn" />
  779. <appender-ref ref="console" />
  780. </root>
  781.  
  782. </log4j:configuration>
  783.  
  784. ★ pom.xml
  785.  
  786. <?xml version="1.0" encoding="UTF-8"?>
  787. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  788. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  789. <modelVersion>4.0.0</modelVersion>
  790. <groupId>com.javalec</groupId>
  791. <artifactId>spring_16_1_ex1_srpingex</artifactId>
  792. <name>spring_16_1_ex1_srpingex</name>
  793. <packaging>war</packaging>
  794. <version>1.0.0-BUILD-SNAPSHOT</version>
  795. <properties>
  796. <java-version>1.6</java-version>
  797. <org.springframework-version>3.1.1.RELEASE</org.springframework-version>
  798. <org.aspectj-version>1.6.10</org.aspectj-version>
  799. <org.slf4j-version>1.6.6</org.slf4j-version>
  800. </properties>
  801. <dependencies>
  802. <!-- Spring -->
  803. <dependency>
  804. <groupId>org.springframework</groupId>
  805. <artifactId>spring-context</artifactId>
  806. <version>${org.springframework-version}</version>
  807. <exclusions>
  808. <!-- Exclude Commons Logging in favor of SLF4j -->
  809. <exclusion>
  810. <groupId>commons-logging</groupId>
  811. <artifactId>commons-logging</artifactId>
  812. </exclusion>
  813. </exclusions>
  814. </dependency>
  815. <dependency>
  816. <groupId>org.springframework</groupId>
  817. <artifactId>spring-webmvc</artifactId>
  818. <version>${org.springframework-version}</version>
  819. </dependency>
  820.  
  821. <!-- AspectJ -->
  822. <dependency>
  823. <groupId>org.aspectj</groupId>
  824. <artifactId>aspectjrt</artifactId>
  825. <version>${org.aspectj-version}</version>
  826. </dependency>
  827.  
  828. <!-- Logging -->
  829. <dependency>
  830. <groupId>org.slf4j</groupId>
  831. <artifactId>slf4j-api</artifactId>
  832. <version>${org.slf4j-version}</version>
  833. </dependency>
  834. <dependency>
  835. <groupId>org.slf4j</groupId>
  836. <artifactId>jcl-over-slf4j</artifactId>
  837. <version>${org.slf4j-version}</version>
  838. <scope>runtime</scope>
  839. </dependency>
  840. <dependency>
  841. <groupId>org.slf4j</groupId>
  842. <artifactId>slf4j-log4j12</artifactId>
  843. <version>${org.slf4j-version}</version>
  844. <scope>runtime</scope>
  845. </dependency>
  846. <dependency>
  847. <groupId>log4j</groupId>
  848. <artifactId>log4j</artifactId>
  849. <version>1.2.15</version>
  850. <exclusions>
  851. <exclusion>
  852. <groupId>javax.mail</groupId>
  853. <artifactId>mail</artifactId>
  854. </exclusion>
  855. <exclusion>
  856. <groupId>javax.jms</groupId>
  857. <artifactId>jms</artifactId>
  858. </exclusion>
  859. <exclusion>
  860. <groupId>com.sun.jdmk</groupId>
  861. <artifactId>jmxtools</artifactId>
  862. </exclusion>
  863. <exclusion>
  864. <groupId>com.sun.jmx</groupId>
  865. <artifactId>jmxri</artifactId>
  866. </exclusion>
  867. </exclusions>
  868. <scope>runtime</scope>
  869. </dependency>
  870.  
  871. <!-- @Inject -->
  872. <dependency>
  873. <groupId>javax.inject</groupId>
  874. <artifactId>javax.inject</artifactId>
  875. <version>1</version>
  876. </dependency>
  877.  
  878. <!-- Servlet -->
  879. <dependency>
  880. <groupId>javax.servlet</groupId>
  881. <artifactId>servlet-api</artifactId>
  882. <version>2.5</version>
  883. <scope>provided</scope>
  884. </dependency>
  885. <dependency>
  886. <groupId>javax.servlet.jsp</groupId>
  887. <artifactId>jsp-api</artifactId>
  888. <version>2.1</version>
  889. <scope>provided</scope>
  890. </dependency>
  891. <dependency>
  892. <groupId>javax.servlet</groupId>
  893. <artifactId>jstl</artifactId>
  894. <version>1.2</version>
  895. </dependency>
  896.  
  897. <!-- Test -->
  898. <dependency>
  899. <groupId>junit</groupId>
  900. <artifactId>junit</artifactId>
  901. <version>4.7</version>
  902. <scope>test</scope>
  903. </dependency>
  904. </dependencies>
  905. <build>
  906. <plugins>
  907. <plugin>
  908. <artifactId>maven-eclipse-plugin</artifactId>
  909. <version>2.9</version>
  910. <configuration>
  911. <additionalProjectnatures>
  912. <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
  913. </additionalProjectnatures>
  914. <additionalBuildcommands>
  915. <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
  916. </additionalBuildcommands>
  917. <downloadSources>true</downloadSources>
  918. <downloadJavadocs>true</downloadJavadocs>
  919. </configuration>
  920. </plugin>
  921. <plugin>
  922. <groupId>org.apache.maven.plugins</groupId>
  923. <artifactId>maven-compiler-plugin</artifactId>
  924. <version>2.5.1</version>
  925. <configuration>
  926. <source>1.6</source>
  927. <target>1.6</target>
  928. <compilerArgument>-Xlint:all</compilerArgument>
  929. <showWarnings>true</showWarnings>
  930. <showDeprecation>true</showDeprecation>
  931. </configuration>
  932. </plugin>
  933. <plugin>
  934. <groupId>org.codehaus.mojo</groupId>
  935. <artifactId>exec-maven-plugin</artifactId>
  936. <version>1.2.1</version>
  937. <configuration>
  938. <mainClass>org.test.int1.Main</mainClass>
  939. </configuration>
  940. </plugin>
  941. </plugins>
  942. </build>
  943. </project>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement