오라클자바커뮤니티에서 설립한 오엔제이프로그래밍
실무교육센터
(오라클SQL, 튜닝, 힌트,자바프레임워크, 안드로이드, 아이폰, 닷넷 실무전문 강의)
간단한 게시판 예제인데 AOP를 적용하여 로그를 남기는 기능을 구현했으며
오라클 Sequence를 사용하기 위해 OracleSequenceMaxValueIncrementer를 사용했습니다.
참조하세요~
1. web.xml(/WEB-INF/)
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<description>Spring Framework</description>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/src/log4j.xml</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/SpringJDBCBoard-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<welcome-file-list>
<welcome-file>/jsp/listBoard.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>EUC-KR</param-value>
</init-param>
</filter>
</web-app>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<description>Spring Framework</description>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/src/log4j.xml</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/SpringJDBCBoard-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<welcome-file-list>
<welcome-file>/jsp/listBoard.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>EUC-KR</param-value>
</init-param>
</filter>
</web-app>
2. SpringJDBCBoard-servlet.xml (/WEB-INF/)
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- DBCP 설정 -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@192.168.1.131:1521:ORCL</value>
</property>
<property name="username">
<value>scott</value>
</property>
<property name="password">
<value>tiger</value>
</property>
</bean>
<bean id="boardDAO" class="board.dao.SpringJdbcDAO">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="incrementer">
<ref local="incrementerManager" />
</property>
</bean>
<bean id="boardService" class="board.service.BoardServiceImpl">
<property name="boardDAO">
<ref local="boardDAO"/>
</property>
</bean>
<bean id="incrementerManager"
class="org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="incrementerName">
<value>SEQ_SID</value> <!-- Oracle Sequenct 이름 -->
</property>
</bean>
<bean id="proxyCreator"
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>board*</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>boardAdvisor</value>
</list>
</property>
<property name="proxyTargetClass">
<value>true</value>
</property>
</bean>
<!--
<bean id="proxyCreator"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target">
<ref bean="boardDAO"/>
</property>
<property name="interceptorNames">
<list>
<value>boardAdvisor</value>
</list>
</property>
<property name="proxyInterfaces">
<value>board.dao.BoardDAO</value>
</property>
</bean>
-->
<bean id="boardAdvisor"
class="org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor">
<property name="advice" ref="myLogger"/>
<property name="expression" value="execution(* *.*(..))"/>
</bean>
<!-- advice -->
<bean id="myLogger" class="board.aop.MyLogger"/>
</beans>
3. commons-logging.properties (/WEB-INF/src)
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
4. log4j.properties(/WEB-INF/src)
(/WEB-INF/src)
5. 로깅을 위한 MyLogger.java (Spring AOP의 사전충고를 구현)
package board.aop;
import java.lang.reflect.Method;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.MethodBeforeAdvice;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.MethodBeforeAdvice;
public class MyLogger implements MethodBeforeAdvice {
protected final Log logger = LogFactory.getLog(getClass());
public void before(Method arg0, Object[] arg1, Object arg2)
throws Throwable {
//대상 메소드의 첫번째 인자를 캐스팅(String productName) …
//String findName = (String)arg1[0];
logger.info(arg0.getName() + "를 시작합니다.");
}//:
}///
protected final Log logger = LogFactory.getLog(getClass());
public void before(Method arg0, Object[] arg1, Object arg2)
throws Throwable {
//대상 메소드의 첫번째 인자를 캐스팅(String productName) …
//String findName = (String)arg1[0];
logger.info(arg0.getName() + "를 시작합니다.");
}//:
}///
6. BoardDAO.java
package board.dao;
import java.util.List;
import board.model.Board;
import board.model.Board;
/**
* @author namheelee
*
*/
public interface BoardDAO {
/**
* @param board
* @return int, boolean, List, Board Obj
* @throws DataAccessException
*/
// 게시물 insert
public int insertBoard(Board board) throws DataAccessException;
// 게시물 update
public int updateBoard(Board board, String sid) throws DataAccessException;
// 게시물 delete
public int deleteBoard(String sid, String password) throws DataAccessException;
// 게시물 List
public List viewBoardList() throws DataAccessException;
// 게시물 내용보기
public Board viewContents(String sid) throws DataAccessException;
// 게시물 비밀번호 체크
}
* @author namheelee
*
*/
public interface BoardDAO {
/**
* @param board
* @return int, boolean, List, Board Obj
* @throws DataAccessException
*/
// 게시물 insert
public int insertBoard(Board board) throws DataAccessException;
// 게시물 update
public int updateBoard(Board board, String sid) throws DataAccessException;
// 게시물 delete
public int deleteBoard(String sid, String password) throws DataAccessException;
// 게시물 List
public List viewBoardList() throws DataAccessException;
// 게시물 내용보기
public Board viewContents(String sid) throws DataAccessException;
// 게시물 비밀번호 체크
}
7. DataAccessException.java
package board.dao;
public class DataAccessException extends RuntimeException {
/**
*
*/
private static final long serialVersionUID = 1L;
*
*/
private static final long serialVersionUID = 1L;
/**
*
*/
public DataAccessException() {
super();
}
*
*/
public DataAccessException() {
super();
}
/**
* @param message
*/
public DataAccessException(String message) {
super(message);
}
* @param message
*/
public DataAccessException(String message) {
super(message);
}
/**
* @param cause
*/
public DataAccessException(Throwable cause) {
super(cause);
}
* @param cause
*/
public DataAccessException(Throwable cause) {
super(cause);
}
/**
* @param message
* @param cause
*/
public DataAccessException(String message, Throwable cause) {
super(message, cause);
}
* @param message
* @param cause
*/
public DataAccessException(String message, Throwable cause) {
super(message, cause);
}
}
8. SpringJdbcDAO.java
package board.dao;
/**
*
* SQL> create table board (
* sid number,
* title varchar2(100),
* author varchar2(50),
* contents varchar2(500),
* insertdate varchar2(20),
* password varchar2(10) );
*
*/
*
* SQL> create table board (
* sid number,
* title varchar2(100),
* author varchar2(50),
* contents varchar2(500),
* insertdate varchar2(20),
* password varchar2(10) );
*
*/
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
import board.model.Board;
public class SpringJdbcDAO implements BoardDAO {
protected final Log logger = LogFactory.getLog(getClass());
private JdbcTemplate jdbcTemplate;
private DataSource dataSource;
public void setDataSource(DataSource dataSource){
this.jdbcTemplate = new JdbcTemplate(dataSource);
org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer a = new org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer();
}
private DataFieldMaxValueIncrementer incrementer;
public void setIncrementer(DataFieldMaxValueIncrementer incrementer)
{
this.incrementer = incrementer;
}
this.incrementer = incrementer;
}
/**
* 집합객체를 맵핑
*/
public List viewBoardList() throws DataAccessException {
// String strQuery = "select sid, title, author, password, contents , insertdate" +
// " from board " +
// " order by sid desc";
* 집합객체를 맵핑
*/
public List viewBoardList() throws DataAccessException {
// String strQuery = "select sid, title, author, password, contents , insertdate" +
// " from board " +
// " order by sid desc";
String strQuery = "select /*+ index_desc(board idx_sid) */ " +
" sid, title, author, password, contents , insertdate" +
" from board " +
" where sid > 0 ";
List boardList = new ArrayList();
boardList = this.jdbcTemplate.query(
strQuery , new RowMapper(){
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
Board board = new Board();
board.setSid(rs.getInt("sid"));
board.setTitle(rs.getString("title"));
board.setAuthor(rs.getString("author"));
board.setPassword(rs.getString("password"));
board.setContents(rs.getString("contents"));
board.setInsertDate(rs.getString("insertdate"));
return board;
}
});
return boardList;
}
/**
* 단일 도메인 객체를 매핑
*/
public Board viewContents(String sid) throws DataAccessException {
String strQuery = "select sid, title, author, password, contents , insertdate" +
" from board " +
" where sid = ? ";
Board board = (Board) this.jdbcTemplate.queryForObject(
strQuery, new Object[]{new String(sid)},
new RowMapper(){
public Object mapRow(ResultSet rs,int rowNum) throws SQLException{
Board board = new Board();
board.setSid(rs.getInt("sid"));
board.setTitle(rs.getString("title"));
board.setAuthor(rs.getString("author"));
board.setPassword(rs.getString("password"));
board.setContents(rs.getString("contents"));
board.setInsertDate(rs.getString("insertdate"));
return board;
}
});
return board;
}
public int deleteBoard(String sid, String password) throws DataAccessException {
int result = 0;
String strQuery = "delete from board" +
" where sid = ? and password = ? ";
result = this.jdbcTemplate.update(strQuery, new Object[]{new Integer(sid), password});
return result;
}
public int insertBoard(Board board) throws DataAccessException
{
int result = 0;
String strQuery = "INSERT INTO BOARD VALUES " +
"( ?, ?, ?, ?, ?, sysdate) ";
int currentSid =new Integer(incrementer.nextIntValue());
result = this.jdbcTemplate.update(strQuery, new Object[]{
new Integer(currentSid), board.getTitle(), board.getAuthor(), board.getPassword(), board.getContents()});
System.out.println("insert result = " + result);
return result;
}
// Max value
// private int getMaxValue() {
// return this.jdbcTemplate.queryForInt(" SELECT /*+ index_desc(board idx_sid ) */ " +
// " max(sid) + 1 as sequence FROM board " +
// " where sid > 0 and rownum = 1" );
// }
int result = 0;
String strQuery = "INSERT INTO BOARD VALUES " +
"( ?, ?, ?, ?, ?, sysdate) ";
int currentSid =new Integer(incrementer.nextIntValue());
result = this.jdbcTemplate.update(strQuery, new Object[]{
new Integer(currentSid), board.getTitle(), board.getAuthor(), board.getPassword(), board.getContents()});
System.out.println("insert result = " + result);
return result;
}
// Max value
// private int getMaxValue() {
// return this.jdbcTemplate.queryForInt(" SELECT /*+ index_desc(board idx_sid ) */ " +
// " max(sid) + 1 as sequence FROM board " +
// " where sid > 0 and rownum = 1" );
// }
public int updateBoard(Board board, String sid) throws DataAccessException
{
int result = 0;
StringBuffer updateQuery = new StringBuffer();
updateQuery.append("\n UPDATE BOARD SET author = ? , \n ");
updateQuery.append(" title = ? , \n ");
updateQuery.append(" password = ? , \n ");
updateQuery.append(" contents = ? , \n ");
updateQuery.append(" insertdate = sysdate \n ");
updateQuery.append(" WHERE sid = ? \n ");
result = this.jdbcTemplate.update(updateQuery.toString(), new Object[]{
board.getAuthor(), board.getTitle(), board.getPassword()
, board.getContents(), new Integer(sid)});
System.out.println("update result = " + result);
return result;
}
int result = 0;
StringBuffer updateQuery = new StringBuffer();
updateQuery.append("\n UPDATE BOARD SET author = ? , \n ");
updateQuery.append(" title = ? , \n ");
updateQuery.append(" password = ? , \n ");
updateQuery.append(" contents = ? , \n ");
updateQuery.append(" insertdate = sysdate \n ");
updateQuery.append(" WHERE sid = ? \n ");
result = this.jdbcTemplate.update(updateQuery.toString(), new Object[]{
board.getAuthor(), board.getTitle(), board.getPassword()
, board.getContents(), new Integer(sid)});
System.out.println("update result = " + result);
return result;
}
}
9. BaseObject.java
package board.model;
import java.io.Serializable;
import org.apache.commons.lang.builder.*;
public class BaseObject implements Serializable{
public String toString(){
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
public boolean equals(Object o){
return EqualsBuilder.reflectionEquals(this, o);
}
public int hashCode(){
return HashCodeBuilder.reflectionHashCode(this);
}
}
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
public boolean equals(Object o){
return EqualsBuilder.reflectionEquals(this, o);
}
public int hashCode(){
return HashCodeBuilder.reflectionHashCode(this);
}
}
10. Board.java
package board.model;
/*
* Board Table 관리를 위하여 필요한 도메인 클래스
* 각 컬럼에 대한 setter, getter를 가진다.
*/
* Board Table 관리를 위하여 필요한 도메인 클래스
* 각 컬럼에 대한 setter, getter를 가진다.
*/
public class Board extends BaseObject{
private int sid = 0; // 순번
private String title = null; // 게시물 제목
private String author = null; // 작성자
private String password = null; // 게시물 비밀번호
private String contents = null; // 게시물 내용
private String insertDate = null; // 작성일
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getContents() {
return contents;
}
public void setContents(String contents) {
this.contents = contents;
}
public String getInsertDate() {
return insertDate;
}
public void setInsertDate(String insertDate) {
this.insertDate = insertDate;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getSid() {
return sid;
}
public void setSid(int sid) {
this.sid = sid;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String toString(){
StringBuffer sb = new StringBuffer();
sb.append("[\n");
sb.append("sid = ");
sb.append(getSid());
sb.append("\n");
sb.append("title = ");
sb.append(getTitle());
sb.append("\n");
sb.append("author = ");
sb.append(getAuthor());
sb.append("\n");
sb.append("]\n");
return sb.toString();
}
}
private int sid = 0; // 순번
private String title = null; // 게시물 제목
private String author = null; // 작성자
private String password = null; // 게시물 비밀번호
private String contents = null; // 게시물 내용
private String insertDate = null; // 작성일
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getContents() {
return contents;
}
public void setContents(String contents) {
this.contents = contents;
}
public String getInsertDate() {
return insertDate;
}
public void setInsertDate(String insertDate) {
this.insertDate = insertDate;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getSid() {
return sid;
}
public void setSid(int sid) {
this.sid = sid;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String toString(){
StringBuffer sb = new StringBuffer();
sb.append("[\n");
sb.append("sid = ");
sb.append(getSid());
sb.append("\n");
sb.append("title = ");
sb.append(getTitle());
sb.append("\n");
sb.append("author = ");
sb.append(getAuthor());
sb.append("\n");
sb.append("]\n");
return sb.toString();
}
}
11. BoardService.java
package board.service;
import java.util.List;
import board.dao.*;
import board.dao.DataAccessException;
import board.model.Board;
import board.dao.*;
import board.dao.DataAccessException;
import board.model.Board;
public interface BoardService {
// 게시물 insert
public int insertBoard(Board board) throws DataAccessException;
// 게시물 update
public int updateBoard(Board board, String sid) throws DataAccessException;
// 게시물 delete
public int deleteBoard(String sid, String password) throws DataAccessException;
// 게시물 List
public List viewBoardList() throws DataAccessException;
// 게시물 내용보기
public Board viewContents(String sid) throws DataAccessException;
}
// 게시물 insert
public int insertBoard(Board board) throws DataAccessException;
// 게시물 update
public int updateBoard(Board board, String sid) throws DataAccessException;
// 게시물 delete
public int deleteBoard(String sid, String password) throws DataAccessException;
// 게시물 List
public List viewBoardList() throws DataAccessException;
// 게시물 내용보기
public Board viewContents(String sid) throws DataAccessException;
}
12. BoardServielper.java
package board.service;
import javax.servlet.ServletContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.web.context.support.WebApplicationContextUtils;
public class BoardServiceHelper {
private static final String BOARDSERVICE_BEANID = "boardService";
private static final String BOARDSERVICE_BEANID = "boardService";
public static BoardService getBoardService(ServletContext ctx)
{
WebApplicationContext wac = WebApplicationContextUtils
.getRequiredWebApplicationContext(ctx);
WebApplicationContext wac = WebApplicationContextUtils
.getRequiredWebApplicationContext(ctx);
return (BoardService) wac.getBean(BOARDSERVICE_BEANID);
}
}
}
}
13. BoardServiceImpl.java
package board.service;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import board.dao.BoardDAO;
import board.dao.DataAccessException;
import board.model.Board;
import org.apache.commons.logging.LogFactory;
import board.dao.BoardDAO;
import board.dao.DataAccessException;
import board.model.Board;
public class BoardServiceImpl implements BoardService {
protected final Log logger = LogFactory.getLog(getClass());
private BoardDAO boardDAO = null;
protected final Log logger = LogFactory.getLog(getClass());
private BoardDAO boardDAO = null;
public void setBoardDAO(BoardDAO boardDAO) {
this.boardDAO = boardDAO;
}
public int insertBoard(Board board) throws DataAccessException {
if (logger.isDebugEnabled()) {
logger.debug("insertBoard() 시작");
logger.debug("Board : " + board);
}
int result = boardDAO.insertBoard(board);
this.boardDAO = boardDAO;
}
public int insertBoard(Board board) throws DataAccessException {
if (logger.isDebugEnabled()) {
logger.debug("insertBoard() 시작");
logger.debug("Board : " + board);
}
int result = boardDAO.insertBoard(board);
if (logger.isDebugEnabled()) {
logger.debug("InsertBoard() 종료");
}
return result;
}
public List viewBoardList() throws DataAccessException {
if (logger.isDebugEnabled()) {
logger.debug("viewBoardList() 시작");
}
List boardList = null;
try {
boardList = boardDAO.viewBoardList();
} catch (DataAccessException e) {
e.printStackTrace();
throw e;
}
logger.debug("InsertBoard() 종료");
}
return result;
}
public List viewBoardList() throws DataAccessException {
if (logger.isDebugEnabled()) {
logger.debug("viewBoardList() 시작");
}
List boardList = null;
try {
boardList = boardDAO.viewBoardList();
} catch (DataAccessException e) {
e.printStackTrace();
throw e;
}
if (logger.isDebugEnabled()) {
if (boardList != null) {
logger.debug("게시물 수 : " + boardList.size());
} else {
logger.debug("게시물 수 : 0");
}
}
if (boardList != null) {
logger.debug("게시물 수 : " + boardList.size());
} else {
logger.debug("게시물 수 : 0");
}
}
if (logger.isDebugEnabled()) {
logger.debug("viewBoardList() 종료");
}
logger.debug("viewBoardList() 종료");
}
return boardList;
}
public int updateBoard(Board board, String sid) throws DataAccessException {
if (logger.isDebugEnabled()) {
logger.debug("updateBoard() 시작");
logger.debug("Board : " + board);
}
}
public int updateBoard(Board board, String sid) throws DataAccessException {
if (logger.isDebugEnabled()) {
logger.debug("updateBoard() 시작");
logger.debug("Board : " + board);
}
int result = 0;
try {
result = boardDAO.updateBoard(board, sid);
} catch (DataAccessException e) {
e.printStackTrace();
throw e;
}
try {
result = boardDAO.updateBoard(board, sid);
} catch (DataAccessException e) {
e.printStackTrace();
throw e;
}
if (logger.isDebugEnabled()) {
logger.debug("updateBoard() 종료");
}
return result;
}
logger.debug("updateBoard() 종료");
}
return result;
}
public int deleteBoard(String sid, String password) throws DataAccessException {
if (logger.isDebugEnabled()) {
logger.debug("deleteBoard() 시작");
logger.debug("sid : " + sid);
logger.debug("password : " + password);
}
int result = 0;
try {
result = boardDAO.deleteBoard(sid, password);
} catch (DataAccessException e) {
e.printStackTrace();
throw e;
}
try {
result = boardDAO.deleteBoard(sid, password);
} catch (DataAccessException e) {
e.printStackTrace();
throw e;
}
if (logger.isDebugEnabled()) {
logger.debug("deleteBoard() 종료");
}
return result;
}
logger.debug("deleteBoard() 종료");
}
return result;
}
public Board viewContents(String sid) throws DataAccessException {
if (logger.isDebugEnabled()) {
logger.debug("viewContents() 시작");
}
Board board = null;
try {
board = boardDAO.viewContents(sid);
} catch (DataAccessException e) {
e.printStackTrace();
throw e;
}
if (logger.isDebugEnabled()) {
logger.debug("viewContents() 시작");
}
Board board = null;
try {
board = boardDAO.viewContents(sid);
} catch (DataAccessException e) {
e.printStackTrace();
throw e;
}
if (logger.isDebugEnabled()) {
if (board != null) {
logger.debug("게시물 번호 " + sid);
} else {
logger.debug("게시물 없음");
}
}
if (board != null) {
logger.debug("게시물 번호 " + sid);
} else {
logger.debug("게시물 없음");
}
}
if (logger.isDebugEnabled()) {
logger.debug("viewContents() 종료");
}
logger.debug("viewContents() 종료");
}
return board;
}
}
}
14. JSP 파일들... Context아래 jsp 디렉토리에 작성
[deleteBoard_action.jsp]
<%@page
contentType="text/html; charset=euc-kr" %>
<%@page import="board.service.BoardService" %>
<%@page import="board.service.BoardServiceHelper" %>
<%@page import="board.service.BoardService" %>
<%@page import="board.service.BoardServiceHelper" %>
<%
String sid = request.getParameter("sid");
String password = new String(request.getParameter("password").getBytes("8859_1"), "MS949");
String password = new String(request.getParameter("password").getBytes("8859_1"), "MS949");
BoardService service = BoardServiceHelper.getBoardService(application);
int result = service.deleteBoard(sid, password);
if(result == 0){
%>
<script language="javascript">
alert("비밀번호가 맞지 않거나 오류가 발생하였습니다.");
history.back();
</script>
%>
<script language="javascript">
alert("비밀번호가 맞지 않거나 오류가 발생하였습니다.");
history.back();
</script>
<%
} else if(result == 1){
%>
<script language="javascript">
alert('삭제되었습니다.');
location.href='./listBoard.jsp';
</script>
<%
}
%>
} else if(result == 1){
%>
<script language="javascript">
alert('삭제되었습니다.');
location.href='./listBoard.jsp';
</script>
<%
}
%>
[deleteBoard.jsp]
<%@page
contentType="text/html; charset=euc-kr" %>
<%
String pageTitle = "Spring 게시판";
String sid = request.getParameter("sid");
%>
<%
String pageTitle = "Spring 게시판";
String sid = request.getParameter("sid");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<link rel="stylesheet" type="text/css" href="./css/style.css"/>
<title><%=pageTitle %></title>
<script language="javascript">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<link rel="stylesheet" type="text/css" href="./css/style.css"/>
<title><%=pageTitle %></title>
<script language="javascript">
function del() {
document.deleteform.action = 'deleteBoard_action.jsp';
document.deleteform.submit();
}
document.deleteform.action = 'deleteBoard_action.jsp';
document.deleteform.submit();
}
</script>
</head>
</head>
<body bgcolor=#FFFFFF text=#000000 leftmargin=0 topmargin=0
marginwidth=0 marginheight=0>
<form name="deleteform" method="post">
<input type="hidden" name="sid" value="<%=sid %>">
<br>
<table class="table_default" border="0" cellpadding="3" cellspacing="1" width="600" align="center" bgcolor="#949EA5">
<tr>
<td bgcolor="f4f4f4" height="22"> <b><%=pageTitle %></b></td>
</tr>
<tr height="80">
<td bgcolor="#FFFFFF" align="center">비밀번호를 입력하세요.
<br><input type="password" name="password" value="" size="17" maxlength="20">
<br>
</td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" align="right">
[
<a href="javascript:del();">삭제</a> |
<a href="javascript:history.back();">취소</a>
]
</td>
</tr>
</table>
</form>
</body>
</html>
<form name="deleteform" method="post">
<input type="hidden" name="sid" value="<%=sid %>">
<br>
<table class="table_default" border="0" cellpadding="3" cellspacing="1" width="600" align="center" bgcolor="#949EA5">
<tr>
<td bgcolor="f4f4f4" height="22"> <b><%=pageTitle %></b></td>
</tr>
<tr height="80">
<td bgcolor="#FFFFFF" align="center">비밀번호를 입력하세요.
<br><input type="password" name="password" value="" size="17" maxlength="20">
<br>
</td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" align="right">
[
<a href="javascript
<a href="javascript
]
</td>
</tr>
</table>
</form>
</body>
</html>
[insertBpard_action.jsp]
<%@page
contentType="text/html; charset=euc-kr" %>
<%@page import="board.model.Board" %>
<%@page import="board.service.BoardService" %>
<%@page import="board.service.BoardServiceHelper" %>
<%@page import="board.model.Board" %>
<%@page import="board.service.BoardService" %>
<%@page import="board.service.BoardServiceHelper" %>
<%
String author = new String(request.getParameter("author").getBytes("8859_1"), "MS949");
String password = new String(request.getParameter("password").getBytes("8859_1"), "MS949");
String title = new String(request.getParameter("title").getBytes("8859_1"), "MS949");
String contents = new String(request.getParameter("contents").getBytes("8859_1"), "MS949");
String author = new String(request.getParameter("author").getBytes("8859_1"), "MS949");
String password = new String(request.getParameter("password").getBytes("8859_1"), "MS949");
String title = new String(request.getParameter("title").getBytes("8859_1"), "MS949");
String contents = new String(request.getParameter("contents").getBytes("8859_1"), "MS949");
Board board = new
Board();
board.setAuthor(author);
board.setPassword(password);
board.setTitle(title);
board.setContents(contents);
BoardService service = BoardServiceHelper.getBoardService(application);
int result = service.insertBoard(board);
if(result > 0){
response.sendRedirect("./listBoard.jsp");
} else {
%>
<script language="javascript">
alert("실패");
</script>
<%
}
%>
board.setAuthor(author);
board.setPassword(password);
board.setTitle(title);
board.setContents(contents);
BoardService service = BoardServiceHelper.getBoardService(application);
int result = service.insertBoard(board);
if(result > 0){
response.sendRedirect("./listBoard.jsp");
} else {
%>
<script language="javascript">
alert("실패");
</script>
<%
}
%>
[insertBoard.jsp]
<%@page
contentType="text/html; charset=euc-kr" %>
<%@page import="java.util.List" %>
<%@page import="java.util.Iterator" %>
<%@page import="board.model.Board" %>
<%@page import="board.service.BoardService" %>
<%@page import="board.service.BoardServiceHelper" %>
<%@page import="java.util.List" %>
<%@page import="java.util.Iterator" %>
<%@page import="board.model.Board" %>
<%@page import="board.service.BoardService" %>
<%@page import="board.service.BoardServiceHelper" %>
<%
String pageTitle = "Spring 게시판";
%>
String pageTitle = "Spring 게시판";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<link rel="stylesheet" type="text/css" href="./css/style.css"/>
<title><%=pageTitle %></title>
<script language="javascript">
function insert() {
document.insertform.action = 'insertBoard_action.jsp';
document.insertform.submit();
}
function listPage() {
document.insertform.action = "listBoard.jsp";
document.insertform.submit();
}
</script>
</head>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<link rel="stylesheet" type="text/css" href="./css/style.css"/>
<title><%=pageTitle %></title>
<script language="javascript">
function insert() {
document.insertform.action = 'insertBoard_action.jsp';
document.insertform.submit();
}
function listPage() {
document.insertform.action = "listBoard.jsp";
document.insertform.submit();
}
</script>
</head>
<body bgcolor=#FFFFFF text=#000000 leftmargin=0 topmargin=0
marginwidth=0 marginheight=0>
<form name="insertform" method="post">
<br>
<table class="table_default" border="0" cellpadding="3" cellspacing="1" width="600" align="center" bgcolor="#949EA5">
<tr>
<td bgcolor="f4f4f4" height="22" colspan="4"> <b><%=pageTitle %></b></td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" width="100" align="center">작성자</td>
<td bgcolor="#FFFFFF" width="200"><input type="text" name="author" value="" size="17"></td>
<td bgcolor="#FFFFFF" width="100" align="center">비밀번호</td>
<td bgcolor="#FFFFFF" width="200"><input type="password" name="password" value="" size="17" maxlength="20"></td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" align="center">제 목</td>
<td bgcolor="#FFFFFF" colspan="3">
<input type="text" name="title" value="" size="60" maxlength="60"/>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" align="center">내 용</td>
<td bgcolor="#FFFFFF" colspan="3">
<textarea name="contents" rows="15" cols="60"></textarea>
</td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" colspan="4" align="right">
[
<a href="javascript:insert();">저장</a> |
<a href="javascript:listPage();">리스트</a>
]
</td>
</tr>
</table>
</form>
</body>
</html>
<form name="insertform" method="post">
<br>
<table class="table_default" border="0" cellpadding="3" cellspacing="1" width="600" align="center" bgcolor="#949EA5">
<tr>
<td bgcolor="f4f4f4" height="22" colspan="4"> <b><%=pageTitle %></b></td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" width="100" align="center">작성자</td>
<td bgcolor="#FFFFFF" width="200"><input type="text" name="author" value="" size="17"></td>
<td bgcolor="#FFFFFF" width="100" align="center">비밀번호</td>
<td bgcolor="#FFFFFF" width="200"><input type="password" name="password" value="" size="17" maxlength="20"></td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" align="center">제 목</td>
<td bgcolor="#FFFFFF" colspan="3">
<input type="text" name="title" value="" size="60" maxlength="60"/>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" align="center">내 용</td>
<td bgcolor="#FFFFFF" colspan="3">
<textarea name="contents" rows="15" cols="60"></textarea>
</td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" colspan="4" align="right">
[
<a href="javascript
<a href="javascript
]
</td>
</tr>
</table>
</form>
</body>
</html>
[updateBoard_action.jsp]
<%@page
contentType="text/html; charset=euc-kr" %>
<%@page import="board.model.Board" %>
<%@page import="board.service.BoardService" %>
<%@page import="board.service.BoardServiceHelper" %>
<%@page import="board.model.Board" %>
<%@page import="board.service.BoardService" %>
<%@page import="board.service.BoardServiceHelper" %>
<%
String author = new String(request.getParameter("author").getBytes("8859_1"), "MS949");
String password = new String(request.getParameter("password").getBytes("8859_1"), "MS949");
String title = new String(request.getParameter("title").getBytes("8859_1"), "MS949");
String contents = new String(request.getParameter("contents").getBytes("8859_1"), "MS949");
String sid = request.getParameter("sid");
String author = new String(request.getParameter("author").getBytes("8859_1"), "MS949");
String password = new String(request.getParameter("password").getBytes("8859_1"), "MS949");
String title = new String(request.getParameter("title").getBytes("8859_1"), "MS949");
String contents = new String(request.getParameter("contents").getBytes("8859_1"), "MS949");
String sid = request.getParameter("sid");
Board board = new
Board();
board.setAuthor(author);
board.setPassword(password);
board.setTitle(title);
board.setContents(contents);
BoardService service = BoardServiceHelper.getBoardService(application);
int result = service.updateBoard(board, sid);
if(result > 0){
response.sendRedirect("./listBoard.jsp");
} else {
%>
<script language="javascript">
alert("실패");
history.back();
</script>
<%
}
%>
board.setAuthor(author);
board.setPassword(password);
board.setTitle(title);
board.setContents(contents);
BoardService service = BoardServiceHelper.getBoardService(application);
int result = service.updateBoard(board, sid);
if(result > 0){
response.sendRedirect("./listBoard.jsp");
} else {
%>
<script language="javascript">
alert("실패");
history.back();
</script>
<%
}
%>
[updateBoard.jsp]
<%@page
contentType="text/html; charset=euc-kr" %>
<%@page import="board.model.Board" %>
<%@page import="board.service.BoardService" %>
<%@page import="board.service.BoardServiceHelper" %>
<%@page import="board.model.Board" %>
<%@page import="board.service.BoardService" %>
<%@page import="board.service.BoardServiceHelper" %>
<%
String pageTitle = "Spring 게시판";
String sid = request.getParameter("sid");
BoardService serivce = BoardServiceHelper.getBoardService(application);
Board boardObj = serivce.viewContents(sid);
%>
String pageTitle = "Spring 게시판";
String sid = request.getParameter("sid");
BoardService serivce = BoardServiceHelper.getBoardService(application);
Board boardObj = serivce.viewContents(sid);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<link rel="stylesheet" type="text/css" href="./css/style.css"/>
<title><%=pageTitle %></title>
<script language="javascript">
function update() {
document.updateform.action = 'updateBoard_action.jsp';
document.updateform.submit();
}
function listPage() {
document.updateform.action = "listBoard.jsp";
document.updateform.submit();
}
</script>
</head>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<link rel="stylesheet" type="text/css" href="./css/style.css"/>
<title><%=pageTitle %></title>
<script language="javascript">
function update() {
document.updateform.action = 'updateBoard_action.jsp';
document.updateform.submit();
}
function listPage() {
document.updateform.action = "listBoard.jsp";
document.updateform.submit();
}
</script>
</head>
<body bgcolor=#FFFFFF text=#000000 leftmargin=0 topmargin=0
marginwidth=0 marginheight=0>
<form name="updateform" method="post">
<input type="hidden" name="sid" value="<%=sid %>">
<br>
<table class="table_default" border="0" cellpadding="3" cellspacing="1" width="600" align="center" bgcolor="#949EA5">
<tr>
<td bgcolor="f4f4f4" height="22" colspan="4"> <b><%=pageTitle %></b></td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" width="100" align="center">작성자</td>
<td bgcolor="#FFFFFF" width="200"><input type="text" name="author" value="<%=boardObj.getAuthor() %>" size="17"></td>
<td bgcolor="#FFFFFF" width="100" align="center">비밀번호</td>
<td bgcolor="#FFFFFF" width="200"><input type="password" name="password" value="<%=boardObj.getPassword() %>" size="17" maxlength="20"></td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" align="center">제 목</td>
<td bgcolor="#FFFFFF" colspan="3">
<input type="text" name="title" value="<%=boardObj.getTitle() %>" size="60" maxlength="60"/>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" align="center">내 용</td>
<td bgcolor="#FFFFFF" colspan="3">
<textarea name="contents" rows="15" cols="60"><%=boardObj.getContents() %></textarea>
</td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" colspan="4" align="right">
[
<a href="javascript:update();">수정</a> |
<a href="javascript:listPage();">리스트</a>
]
</td>
</tr>
</table>
</form>
</body>
</html>
<form name="updateform" method="post">
<input type="hidden" name="sid" value="<%=sid %>">
<br>
<table class="table_default" border="0" cellpadding="3" cellspacing="1" width="600" align="center" bgcolor="#949EA5">
<tr>
<td bgcolor="f4f4f4" height="22" colspan="4"> <b><%=pageTitle %></b></td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" width="100" align="center">작성자</td>
<td bgcolor="#FFFFFF" width="200"><input type="text" name="author" value="<%=boardObj.getAuthor() %>" size="17"></td>
<td bgcolor="#FFFFFF" width="100" align="center">비밀번호</td>
<td bgcolor="#FFFFFF" width="200"><input type="password" name="password" value="<%=boardObj.getPassword() %>" size="17" maxlength="20"></td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" align="center">제 목</td>
<td bgcolor="#FFFFFF" colspan="3">
<input type="text" name="title" value="<%=boardObj.getTitle() %>" size="60" maxlength="60"/>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" align="center">내 용</td>
<td bgcolor="#FFFFFF" colspan="3">
<textarea name="contents" rows="15" cols="60"><%=boardObj.getContents() %></textarea>
</td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" colspan="4" align="right">
[
<a href="javascript
<a href="javascript
]
</td>
</tr>
</table>
</form>
</body>
</html>
[listBoard.jsp]
<%@page
contentType="text/html; charset=euc-kr" %>
<%@page import="java.util.List" %>
<%@page import="java.util.Iterator" %>
<%@page import="board.model.Board" %>
<%@page import="board.service.BoardService" %>
<%@page import="board.service.BoardServiceHelper" %>
<%@page import="java.util.List" %>
<%@page import="java.util.Iterator" %>
<%@page import="board.model.Board" %>
<%@page import="board.service.BoardService" %>
<%@page import="board.service.BoardServiceHelper" %>
<%
//모델을 이용하여 사용자 리스트를 가져온다.
String pageTitle = "Spring 게시판";
//모델을 이용하여 사용자 리스트를 가져온다.
String pageTitle = "Spring 게시판";
BoardService service =
BoardServiceHelper.getBoardService(application);
List viewList = service.viewBoardList();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<link rel="stylesheet" type="text/css" href="./css/style.css"/>
<title><%=pageTitle %></title>
<script language="javascript">
function insertPage() {
document.listform.action = 'insertBoard.jsp';
document.listform.submit();
}
</script>
</head>
List viewList = service.viewBoardList();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<link rel="stylesheet" type="text/css" href="./css/style.css"/>
<title><%=pageTitle %></title>
<script language="javascript">
function insertPage() {
document.listform.action = 'insertBoard.jsp';
document.listform.submit();
}
</script>
</head>
<body bgcolor=#FFFFFF text=#000000 leftmargin=0 topmargin=0
marginwidth=0 marginheight=0>
<form name="listform">
<br>
<table width="600" border="0" align="center" class="table_default">
<tr>
<td bgcolor="f4f4f4" height="22"> <b><%=pageTitle %></b></td>
</tr>
<tr>
<td>
<!-- 리스트 출력 -->
<table border="0" width="100%" cellpadding="0" cellspacing="1" bgcolor="BBBBBB">
<tr>
<td width=10% align=center bgcolor="E6ECDE" height="22">SID</td>
<td width=50% align=center bgcolor="E6ECDE">Subject</td>
<td align=center bgcolor="E6ECDE">Author</td>
<td width=20% align=center bgcolor="E6ECDE">Date</td>
</tr>
<%
Iterator boardIter = viewList.iterator();
while ( boardIter.hasNext() ) {
Board board = (Board)boardIter.next();
%>
<tr>
<td width=10% align=center bgcolor="ffffff" height="20">
<%= board.getSid() %>
</td>
<td width=50% bgcolor="ffffff">
<a href="viewBoard.jsp?sid=<%=board.getSid()%>">
<%= board.getTitle() %>
</a>
</td>
<td align=center bgcolor="ffffff">
<%= board.getAuthor() %>
</td>
<td width=20% align=center bgcolor="ffffff">
<%= board.getInsertDate() %>
</td>
</tr>
<%
}
%>
</table>
<!-- 리스트 출력 끝 -->
</td>
</tr>
<tr>
<td align="right">
<input type="button" onClick="javascript:insertPage();" value="글
입력"/>
</td>
</tr>
</table>
</form>
</body>
</html>
<form name="listform">
<br>
<table width="600" border="0" align="center" class="table_default">
<tr>
<td bgcolor="f4f4f4" height="22"> <b><%=pageTitle %></b></td>
</tr>
<tr>
<td>
<!-- 리스트 출력 -->
<table border="0" width="100%" cellpadding="0" cellspacing="1" bgcolor="BBBBBB">
<tr>
<td width=10% align=center bgcolor="E6ECDE" height="22">SID</td>
<td width=50% align=center bgcolor="E6ECDE">Subject</td>
<td align=center bgcolor="E6ECDE">Author</td>
<td width=20% align=center bgcolor="E6ECDE">Date</td>
</tr>
<%
Iterator boardIter = viewList.iterator();
while ( boardIter.hasNext() ) {
Board board = (Board)boardIter.next();
%>
<tr>
<td width=10% align=center bgcolor="ffffff" height="20">
<%= board.getSid() %>
</td>
<td width=50% bgcolor="ffffff">
<a href="viewBoard.jsp?sid=<%=board.getSid()%>">
<%= board.getTitle() %>
</a>
</td>
<td align=center bgcolor="ffffff">
<%= board.getAuthor() %>
</td>
<td width=20% align=center bgcolor="ffffff">
<%= board.getInsertDate() %>
</td>
</tr>
<%
}
%>
</table>
<!-- 리스트 출력 끝 -->
</td>
</tr>
<tr>
<td align="right">
<input type="button" onClick="javascript
</td>
</tr>
</table>
</form>
</body>
</html>
[viewBoard.jsp]
<%@page
contentType="text/html; charset=euc-kr" %>
<%@page import="board.model.Board" %>
<%@page import="board.service.BoardService" %>
<%@page import="board.service.BoardServiceHelper" %>
<%@page import="board.model.Board" %>
<%@page import="board.service.BoardService" %>
<%@page import="board.service.BoardServiceHelper" %>
<%
String pageTitle = "Spring 게시판";
String sid = request.getParameter("sid");
BoardService serivce = BoardServiceHelper.getBoardService(application);
Board boardObj = serivce.viewContents(sid);
%>
String pageTitle = "Spring 게시판";
String sid = request.getParameter("sid");
BoardService serivce = BoardServiceHelper.getBoardService(application);
Board boardObj = serivce.viewContents(sid);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<link rel="stylesheet" type="text/css" href="./css/style.css"/>
<title><%=pageTitle %></title>
<script language="javascript">
function update(){
document.viewform.action = 'updateBoard.jsp';
document.viewform.submit();
}
function del(){
document.viewform.action = 'deleteBoard.jsp';
document.viewform.submit();
}
function listPage(){
document.viewform.action = "listBoard.jsp";
document.viewform.submit();
}
</script>
</head>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<link rel="stylesheet" type="text/css" href="./css/style.css"/>
<title><%=pageTitle %></title>
<script language="javascript">
function update(){
document.viewform.action = 'updateBoard.jsp';
document.viewform.submit();
}
function del(){
document.viewform.action = 'deleteBoard.jsp';
document.viewform.submit();
}
function listPage(){
document.viewform.action = "listBoard.jsp";
document.viewform.submit();
}
</script>
</head>
<body bgcolor=#FFFFFF text=#000000 leftmargin=0 topmargin=0
marginwidth=0 marginheight=0>
<form name="viewform" method="post">
<input type="hidden" name="sid" value="<%=sid %>">
<br>
<table class="table_default" border="0" cellpadding="3" cellspacing="1" width="600" align="center" bgcolor="#949EA5">
<tr>
<td bgcolor="f4f4f4" height="22" colspan="4"> <b><%=pageTitle %></b></td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" width="100" align="center">작성자</td>
<td bgcolor="#FFFFFF" width="200"><%= boardObj.getAuthor() %></td>
<td bgcolor="#FFFFFF" width="100" align="center">작성일</td>
<td bgcolor="#FFFFFF" width="200"><%= boardObj.getInsertDate() %></td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" align="center">제 목</td>
<td bgcolor="#FFFFFF" colspan="3">
<%= boardObj.getTitle() %>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" align="center">내 용</td>
<td bgcolor="#FFFFFF" colspan="3">
<%= boardObj.getContents() %>
<BR><BR><font color="#FFFFFF"><%= boardObj.getPassword() %></font>
</td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" colspan="4" align="right">
[
<a href="javascript:del();">삭제</a> | <a href="javascript:update();">수정</a> |
<a href="javascript:listPage();">리스트</a>
]
</td>
</tr>
</table>
</form>
</body>
</html>
<form name="viewform" method="post">
<input type="hidden" name="sid" value="<%=sid %>">
<br>
<table class="table_default" border="0" cellpadding="3" cellspacing="1" width="600" align="center" bgcolor="#949EA5">
<tr>
<td bgcolor="f4f4f4" height="22" colspan="4"> <b><%=pageTitle %></b></td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" width="100" align="center">작성자</td>
<td bgcolor="#FFFFFF" width="200"><%= boardObj.getAuthor() %></td>
<td bgcolor="#FFFFFF" width="100" align="center">작성일</td>
<td bgcolor="#FFFFFF" width="200"><%= boardObj.getInsertDate() %></td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" align="center">제 목</td>
<td bgcolor="#FFFFFF" colspan="3">
<%= boardObj.getTitle() %>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" align="center">내 용</td>
<td bgcolor="#FFFFFF" colspan="3">
<%= boardObj.getContents() %>
<BR><BR><font color="#FFFFFF"><%= boardObj.getPassword() %></font>
</td>
</tr>
<tr height="30">
<td bgcolor="#FFFFFF" colspan="4" align="right">
[
<a href="javascript
<a href="javascript
]
</td>
</tr>
</table>
</form>
</body>
</html>
실행
Context이름이 jdbc2라고 할때
댓글 없음:
댓글 쓰기