origoni's Blog from Millky

origoni의 스프링 블로그 입니다.

자바 웹 개발

자바웹개발_1주차.pdf
자바웹개발_계획.pdf

http://helloworldsite.he.funpic.de/

 

 

 

writeform.jsp

 d.jsp

hw.jsp

 index.jsp

u.jsp

 uf.jsp

write.jsp

 

 

와 이럴수가.

생각보다 시간이 1.5배로 걸린다.

물론 이것저것 버벅인것도 있지만... 실제 환경에서 데모도 안해보고...


음....윈도우에서 데모 할때와 OSX에서 할때가.. 이렇게 다를줄은 몰랐다 ㅠㅠ


역시. 데모를 잘 해봐야 해.

 



http://www.springsource.org/


http://hibernate.org/




int idx = Integer.parseInt(request.getParameter("idx"));


">


String query = "update test set subject = '" + subject + "' "

+ "where idx = '" + idx + "'";


String query = "delete from test where idx = '" + idx + "'";




압축


web.xml


example

org.springframework.web.servlet.DispatcherServlet

1


example

*.do



라이브러리



example-servlet.xml


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd">




StudyController


@RequestMapping(value = { "/hw.do" }, method = RequestMethod.GET)

public String showMain(Model model) {

model.addAttribute("data", "hello world");

return "/hw.jsp";

}




web.xml


org.springframework.web.context.ContextLoaderListener




applicationContext.xml


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:mvc="http://www.springframework.org/schema/mvc"

xsi:schemaLocation="

        http://www.springframework.org/schema/beans 

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/mvc

http://www.springframework.org/schema/mvc/spring-mvc.xsd

http://www.springframework.org/schema/context 

http://www.springframework.org/schema/context/spring-context-3.0.xsd">




http://commons.apache.org/dbcp/


http://commons.apache.org/pool/






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:mvc="http://www.springframework.org/schema/mvc"

xsi:schemaLocation="

        http://www.springframework.org/schema/beans 

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/mvc

http://www.springframework.org/schema/mvc/spring-mvc.xsd

http://www.springframework.org/schema/context 

http://www.springframework.org/schema/context/spring-context-3.0.xsd">



destroy-method="close">





class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">



org.hibernate.dialect.MySQL5InnoDBDialect

true

true

true


update








EntityBeanFinderFactoryBean


package com.starpl.study;


import java.io.BufferedInputStream;

import java.io.DataInputStream;

import java.io.InputStream;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;


import org.springframework.beans.factory.FactoryBean;

import org.springframework.context.ResourceLoaderAware;

import org.springframework.core.io.Resource;

import org.springframework.core.io.ResourceLoader;

import org.springframework.core.io.support.ResourcePatternResolver;


/**

 *

 * This class finds all @Entity annotated classes defined by an ANT style class name pattern.

 * Default pattern is **.entity.**

 *

 * @author marcus.bristav@dreampark.com

 * @version 1.1 edit by byuri

 */

public class EntityBeanFinderFactoryBean implements ResourceLoaderAware,

FactoryBean

{

private ResourcePatternResolver resolver;

@SuppressWarnings("rawtypes")

private List managedClasses = null;

private String classPattern = "classpath*:**/entity/**/*.class";

static final int UTF = 1, INTEGER = 3, FLOAT = 4, LONG = 5, DOUBLE = 6,

CLASS = 7, STRING = 8, FIELD_REF = 9, METHOD_REF = 10,

INTERFACE_METHOD_REF = 11, NAME_AND_TYPE = 12;


@Override

public void setResourceLoader(ResourceLoader resourceLoader)

{

resolver = (ResourcePatternResolver) resourceLoader;

}


@Override

public Object getObject() throws Exception

{

if (managedClasses == null)

{

loadManagedClasses();

}

return managedClasses;

}

@Override

public Class getObjectType()

{

return List.class;

}


@Override

public boolean isSingleton()

{

return true;

}


@SuppressWarnings("rawtypes")

private void loadManagedClasses() throws Exception

{

managedClasses = new ArrayList();

Resource[] resources = resolver.getResources(classPattern);


if (resources != null)

{

for (Resource res : resources)

{

Class klass = getClass(res);

if (hasEntityAnnotation(klass))

{

managedClasses.add(klass);

}

}

}

}


private Class getClass(Resource res) throws Exception

{

String className = className(res);

return Class.forName(className);

}


private boolean hasEntityAnnotation(Class klass)

{

return (klass.getAnnotation(javax.persistence.Entity.class) != null);

}


private String className(Resource res) throws Exception

{

InputStream is = res.getInputStream();

Map offsetTable = new HashMap();

Map classNameTable = new HashMap();

DataInputStream data = new DataInputStream(new BufferedInputStream(is));

int constant_pool_count = data.readShort();

for (int i = 1; i < constant_pool_count; i++)

{

int tag = data.read();

switch (tag)

{

case CLASS:

int offset = data.readShort();

offsetTable.put(i, offset);

break;

case UTF:

int length = data.readShort();

char[] bytes = new char[length];

for (int k = 0; k < bytes.length; k++)

{

bytes[k] = (char) data.read();

}

String className = new String(bytes);

classNameTable.put(i, className);

break;

case LONG:

case DOUBLE:

data.readLong();

i++;

break;

case STRING:

data.readShort();

break;

default:

data.readInt();

}

}


int this_class = data.readShort();

String thisClassName = classNameTable.get(offsetTable.get(this_class));

is.close();

return thisClassName.replace("/", ".");

}

}






Test

package com.starpl.study.entity;


import javax.persistence.Column;

import javax.persistence.Entity;

import javax.persistence.GeneratedValue;

import javax.persistence.GenerationType;

import javax.persistence.Id;

import javax.persistence.Table;


@Entity

@Table(name = "test")

public class Test {

@Id

@GeneratedValue(strategy = GenerationType.AUTO)

@Column(name = "idx")

private int idx; // PK, 자동생성


@Column(name = "subject", length = 500)

private String subject;

}



1주차.txt

 


 


◀ 10/27 2011 15:23:48
세금 납부
10/24 2011 21:47:54
현기야...
back to top