'jsp2.0'에 해당되는 글 15건

  1. 2014.10.20 2014-10-20
  2. 2014.10.17 2014-10-17
  3. 2014.10.16 2014-10-16
  4. 2014.10.15 2014-10-15 인터셉터-파일 업로드
  5. 2014.10.15 2014-10-15 인터셉터- servletConfig
  6. 2014.10.15 2014-10-15 checkbox
  7. 2014.10.15 2014-10-15 인터셉터
  8. 2014.10.14 2014-10-14 인터셉터
  9. 2014.10.13 2014-10-13 Struts2
  10. 2014.10.08 2014-10-08

2014-10-20

jsp2.0 2014. 10. 20. 10:02

view =>jstl

'jsp2.0' 카테고리의 다른 글

2014-10-17  (0) 2014.10.17
2014-10-16  (0) 2014.10.16
2014-10-15 인터셉터-파일 업로드  (0) 2014.10.15
2014-10-15 인터셉터- servletConfig  (0) 2014.10.15
2014-10-15 checkbox  (0) 2014.10.15
Posted by 5DMK2]발자국
,

2014-10-17

jsp2.0 2014. 10. 17. 12:04

<typeAlias alias="board" type="board.boardVO" />

alias는 변수명


<sql id="where-no">

WHERE no = #no#

</sql>

ibatis에서 #은 ?표


// 모든 글을 가져와 list에 넣는다.  queryForObject <- 결과가 하나 일 때 사용

list = sqlMapper.queryForList("selectAll");//결과 여러개 일 때 사용



SELECT max(no) as no FROM sBOARD  <!-- 쿼리문 실행하면 max(no)로 나옴  as no를 붙여서 no로 나오게 함-->


sqlMapconfig.xml

 useStatementNamespaces="false" 

false이면 ID가 중복이면 사용 못함

true이면 sql에서 이름 설정 가능

(SQL.xml에서 <sqlMap name="">에 지정 가능)

'jsp2.0' 카테고리의 다른 글

2014-10-20  (0) 2014.10.20
2014-10-16  (0) 2014.10.16
2014-10-15 인터셉터-파일 업로드  (0) 2014.10.15
2014-10-15 인터셉터- servletConfig  (0) 2014.10.15
2014-10-15 checkbox  (0) 2014.10.15
Posted by 5DMK2]발자국
,

2014-10-16

jsp2.0 2014. 10. 16. 13:19

1 => ${name}

<br>

null값이면 아무것도 안나옴

2 => <s:property value="name" default="abc" escape="false" />

<br>

 default="abc" null값을 때 abc로 나옴

3 => <s:property value="#parameters.name" />

'jsp2.0' 카테고리의 다른 글

2014-10-20  (0) 2014.10.20
2014-10-17  (0) 2014.10.17
2014-10-15 인터셉터-파일 업로드  (0) 2014.10.15
2014-10-15 인터셉터- servletConfig  (0) 2014.10.15
2014-10-15 checkbox  (0) 2014.10.15
Posted by 5DMK2]발자국
,

파일 업로드 인터셉터

1. 파일 객체(필수)

public vodi setDoc(File doc){

this.doc = doc;

}

2. 파일 이름

public void setDoccontextType(String docContentType){

this.docContentType= docContentType;

}

3. 파일 타입

public void setDocFileName(String docFileName){

this.docFileName = docFileName;

}


struts.xml에서

<interceptor-ref name ="fileuploda">는

<interceptor-ref name ="params">위에 있어야 한다



16


21


'jsp2.0' 카테고리의 다른 글

2014-10-17  (0) 2014.10.17
2014-10-16  (0) 2014.10.16
2014-10-15 인터셉터- servletConfig  (0) 2014.10.15
2014-10-15 checkbox  (0) 2014.10.15
2014-10-15 인터셉터  (0) 2014.10.15
Posted by 5DMK2]발자국
,
session.setAttibute("memId",id);

HttpSession session = request.getSession();

session.setAttribute("memId",id);


session.getAttribute("memId");


Map session;

session.put("memId",id);

session.get("memId");



'jsp2.0' 카테고리의 다른 글

2014-10-16  (0) 2014.10.16
2014-10-15 인터셉터-파일 업로드  (0) 2014.10.15
2014-10-15 checkbox  (0) 2014.10.15
2014-10-15 인터셉터  (0) 2014.10.15
2014-10-14 인터셉터  (0) 2014.10.14
Posted by 5DMK2]발자국
,

2014-10-15 checkbox

jsp2.0 2014. 10. 15. 10:26

<form action=”checkbox.action”>

    <input type=”checkbox” name=”male” value=”true”/>

    <input type=”hidden” name=”__checkbox_male” />남성

</form>

hidden타입과 _checkbox_name값 넣어 주어야 한다



'jsp2.0' 카테고리의 다른 글

2014-10-15 인터셉터-파일 업로드  (0) 2014.10.15
2014-10-15 인터셉터- servletConfig  (0) 2014.10.15
2014-10-15 인터셉터  (0) 2014.10.15
2014-10-14 인터셉터  (0) 2014.10.14
2014-10-13 Struts2  (0) 2014.10.13
Posted by 5DMK2]발자국
,

2014-10-15 인터셉터

jsp2.0 2014. 10. 15. 09:54

<interceptors>

<interceptor-stack name="aaa">

<interceptor-ref name="prepare">

</interceptor-stack name="aaa">

</interceptors>



'jsp2.0' 카테고리의 다른 글

2014-10-15 인터셉터- servletConfig  (0) 2014.10.15
2014-10-15 checkbox  (0) 2014.10.15
2014-10-14 인터셉터  (0) 2014.10.14
2014-10-13 Struts2  (0) 2014.10.13
2014-10-08  (0) 2014.10.08
Posted by 5DMK2]발자국
,

2014-10-14 인터셉터

jsp2.0 2014. 10. 14. 09:34

사용자 요청이 Action에 도달하기 전에 가로 채 Action 실행 전 후에 다른 실행 코드를 넣을 수 있는 객체


controller에


<action name="hello" class="struts.hello.HelloAction">

<result name="success">/1013/hello.jsp</result>

</action>

action result 사이에

<interceptor-ref name="params" />

<interceptor-ref name="workflw" />생략 되어 있어서 안써도 됨(이미 정의 되어 있음)


직접 만든 인터셉트를 사용할 때는 인터셉터를 모두 넣어 주어야 한다(생략된 인터셉터는 동작 안함) 액션마다 해주어야 함




public String intercept(ActionInvocation arg0) throws Exception{

System.out.println("전 인터셉터");

String str = arg0.invoke();

// 목적지 Action의 execute 메서드 호출 

//invoke 기준으로 전 인터셉터 후 인터셉터 나눠짐

System.out.println("후 인터셉터");

return str;

}




<interceptors> 

<interceptor name="test" class="struts.test.TestInterceptor"></interceptor>

</interceptors>

인터셉터는 패키지 바로 밑에 있어야 하고 action위에 있어야 됨

'jsp2.0' 카테고리의 다른 글

2014-10-15 checkbox  (0) 2014.10.15
2014-10-15 인터셉터  (0) 2014.10.15
2014-10-13 Struts2  (0) 2014.10.13
2014-10-08  (0) 2014.10.08
2014-10-07  (0) 2014.10.07
Posted by 5DMK2]발자국
,

2014-10-13 Struts2

jsp2.0 2014. 10. 13. 09:52





Java Resources -> src -> struts.xml생성


web.xml 파일

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">

<filter>

<filter-name>struts2</filter-name>

<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>

</filter>

<filter-mapping>

<filter-name>struts2</filter-name>

<url-pattern>/*</url-pattern>                    //              /* <==모든 주소 받음

</filter-mapping>

</web-app>


상수

public static final String SUCCESS = "success";  기본값

public static final String NONE = "none";     정상처리 되었지만 view 필요 없을 때

public static final String ERROR = "error";

public static final String INPUT = "input";     파라미터가 못 왔을 때 

public static final String LOGIN = "login";    로그인 실패 했을 때 




struts.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="" extends="">
<action name="" class="">
<result></result>
</action>
</package>

</struts>
추가

    


실행방법

http://localhost:8000/struts/hello.aciton

프로젝트 이름/ 액션 테그 이름


pojo방식

aaa.java 

execute가 기본 메서드

메서드 이름 변경 후 

struts.xml파일에 

<action name="test" class="struts.hello.TestAction"> 에 메서드 이름 추가하면 메서드 사용 가능

method="abcd"





Validateable 유효성 검사




1.set 먼저 동작

2.Validateable - set메서드에 들어온 값을 확인

3. execute



Struts =>기본 설정이 되어있다.


request.getParamater ==> setXXXX

request.setAttribute ==> getXXX


'jsp2.0' 카테고리의 다른 글

2014-10-15 인터셉터  (0) 2014.10.15
2014-10-14 인터셉터  (0) 2014.10.14
2014-10-08  (0) 2014.10.08
2014-10-07  (0) 2014.10.07
10-01 슈퍼인터페이스  (0) 2014.10.01
Posted by 5DMK2]발자국
,

2014-10-08

jsp2.0 2014. 10. 8. 09:26

1. 로그인 후 글쓰기

jsp파일에서<c:if test="${memId == null}"> 로 로그인 설정 하여 로그인 되었을 때

글쓰기 버튼 활성화


2. 작성자는 로그인된 ID

작성자 : ${memID} 


3. 나의 작성 글목록

자바파일에서 String id = (String)session.getAttribute("memID");


id값으로 쿼리문 날려서 결과 값을 받은 후

list= select * from board where id=? 

글 리스트 자바파일에서  

request.setAttribute("list", list);

값을 넣고 리스트 jsp파일에서

<c:forEach var="list" items="${list}">

와 같이 넣는다


4. 비밀번호 확인 후 글 읽기 + 관리자는 모두 읽기 가능

클릭한 글 번호

int num = Integer.parseInt(req.getParameter("num"));

와 해당 글의 비밀번호

String passwd = request.getParameter("passwd");

를 받고 해당 글의 번호와 비밀번호를 

int check = selct passwd from board where num=?

하여 쿼리문을 날려서 받아옴 

리턴 받은 값을

자바 파일에서 if문을 사용하여 비밀 번호가 같으면 글 내용을 

if(check ==1){ 글 내용 페이지}

}else{

경고 창 띄움

}


5. 관리자만 답변가능

관리자 ID(adminID)설정 된 상태에서

String id = (String)session.getAttribute("memId");

로그인된 ID와 관리자와 같으면

if(id.equals("adminID)){

String adminID = "adminID";

req.setAttribute("adminID", adminID);

}

JSP 파일에서 로그인 된 ID와 관리자 ID가 같으면

<c:if test="${memId == adminID}"> 

답변 버튼 기능 활성화


6. 관리자만 글쓰기 가능

관리자 ID(adminID)설정 된 상태에서

String id = (String)session.getAttribute("memId");

로그인된 ID와 관리자와 같으면

if(id.equals("adminID)){

String adminID = "adminID";

req.setAttribute("adminID", adminID);

}

JSP 파일에서 로그인 된 ID와 관리자 ID가 같으면

<c:if test="${memId == adminID}"> 

글쓰기 버튼 기능 활성화


7. 쿠키를 활용한 자동 로그인


쿠키 생성

Cookie coo1 = new Cookie("memId", "id");

Cookie coo2 = new Cookie("passwd", "passwd");

coo1.setPath("/");

coo2.setPath("/");

coo1.setMaxAge(3000); //쿠키 시간 설정

coo2.setMaxAge(3000); 

response.addCookie(coo1);

response.addCookie(coo2);

키 불러오기

Cookie[] cookies = request.getCookies();

if(cookies  != null){

for(int i = 0; i < cookies.length; i++){

Cookie thisCookie = cookies[i];

HttpSession session = reqeust.getSession();

session.setAttribute("memId", id);

}

}

'jsp2.0' 카테고리의 다른 글

2014-10-14 인터셉터  (0) 2014.10.14
2014-10-13 Struts2  (0) 2014.10.13
2014-10-07  (0) 2014.10.07
10-01 슈퍼인터페이스  (0) 2014.10.01
모델2기반의 MVC패턴  (0) 2014.09.30
Posted by 5DMK2]발자국
,