블로그 이미지
박공명

카테고리

분류 전체보기 (99)
된장 (7)
Dev (60)
꼐..꼐임 (6)
식탐 (18)
우리 (0)
Etc (8)
개인자료 (0)
Total
Today
Yesterday

영문 숫자 조합의 문자열을 바이트별로 잘라야할 일이 생겼다.


인터넷 검색결과 보통 타이틀 길이를 제한하기위한 용도로만 사용하기에 어쩔수없이 새로만듬.


원하는 바이트의 배열 숫자만큼 그리고 길이가 초과하면 빈칸으로 채운 list를 반환한다.



결과 :

INFO : com.x2trade.base.controller.javaTest - 하이요1

INFO : com.x2trade.base.controller.javaTest - 하이요2

INFO : com.x2trade.base.controller.javaTest - 하이요3

INFO : com.x2trade.base.controller.javaTest - 하이요4

INFO : com.x2trade.base.controller.javaTest - 하이요5

INFO : com.x2trade.base.controller.javaTest - 

INFO : com.x2trade.base.controller.javaTest - 


소스 :

public void testSampleView()

{

String str = new String("하이요1하이요2하이요3하이요4하이요5");

List<String> strList = cutString(str,10,10,10,10,10,10,10);

for(String a : strList) {

logger.info(a);

}

}        

public List<String> cutString(String str,int...cuttingBytes) {

List<String> rtnList = new ArrayList<String>();

if(str == null) str = "";

int maxLength = str.length();

int i=0;

for(int cutBytes : cuttingBytes) {

StringBuffer sb = new StringBuffer("");

if(i>maxLength) {

rtnList.add("");

break;

}

for(;i<maxLength;i++) {

if(sb.toString().getBytes("utf-8").length + str.substring(i, i+1).getBytes("utf-8").length > cutBytes) break;

sb.append(str.substring(i, i+1));

}

rtnList.add(sb.toString());

}

return rtnList;

}

'Dev > Java' 카테고리의 다른 글

자바 컴파일 클래스패스 지정  (0) 2010.04.01
java.sql.SQLException: 스트림이 이미 종료되었습니다  (0) 2010.03.25
Full GC  (0) 2010.03.25
ftp upload  (0) 2010.03.24
ftp 파일삭제.  (0) 2010.03.24
Posted by 박공명
, |

아오 개빡칠뻔했음


캐릭터셋문제인건 알았는데 라즈베리파이에서의 xbmc 설정이 어딘지를 몰랐기때문


인터넷 뒤져봐두 안나오더라고 


그래서 안나와서 못햇냐? 그건 아니지 내가 찾았거든


pi@raspberrypi /usr/share/xbmc/language/Korean $ sudo nano langinfo.xml


캐릭터셋이 utf-8 이면 해결된다.

오늘도 즐겁군.


Posted by 박공명
, |

별거 아니면서도 자주 안쓰면서도 종종 써서 빡치게하는 POI


다음부터라도 편하게 사용하기위하여 정리를 해야겟다.


Maven 기본이져 ?


        <dependency>

   <groupId>org.apache.poi</groupId>

   <artifactId>poi</artifactId>

   <version>3.9</version>

</dependency> 

 

 <dependency>

   <groupId>org.apache.poi</groupId>

   <artifactId>poi-ooxml</artifactId>

   <version>3.9</version>

</dependency>


두개를 추가함으로서 HSSF , XSSF를 사용할수 있게된다


전자는 옜날버젼 후자는 통합문서를 사용할수있게한다.


두개를 같이 사용하기 위하여 파일 확장자를 확인하여 구분하도록 한다


String fileName = File.getOriginalFilename();

logger.info("fileName : {}",fileName);

String fileExt = fileName.substring(fileName.lastIndexOf(".")+1);

logger.info("fileExt : {}",fileExt);

POIFSFileSystem fs = null;

Workbook workBook = null;

if(fileExt.equals("xls")) {

fs = new POIFSFileSystem(File.getInputStream());

workBook = new HSSFWorkbook(fs);

} else if(fileExt.equals("xlsx")) {

workBook = new XSSFWorkbook(File.getInputStream());

}

Sheet sheet = workBook.getSheetAt(0);

int rows = sheet.getPhysicalNumberOfRows();

for(int r=0; r<rows; r++){

Row row = sheet.getRow(r);

String storeNo = "";

String storeName = "";

if(row != null){

for(int c=0; c<2; c++){

Cell cell = row.getCell(c);

if(cell != null) {

switch(cell.getCellType()) {

case HSSFCell.CELL_TYPE_NUMERIC:

if(c == 0) {

storeNo = String.valueOf((int)cell.getNumericCellValue());

} else if(c == 1) {

storeName = String.valueOf(cell.getNumericCellValue());

}

break;

case HSSFCell.CELL_TYPE_STRING:

if(c == 0) {

storeNo = cell.getStringCellValue();

} else if(c == 1) {

storeName = cell.getStringCellValue();

}

break;

case HSSFCell.CELL_TYPE_BLANK:

throw new Exception();

}

}

}

logger.info("{} \t {}",storeNo,storeName);

}

}

Posted by 박공명
, |

ASCII 코드표

Dev / 2014. 2. 28. 17:45


http://www.theasciicode.com.ar/


간지남.

Posted by 박공명
, |

Spring Security 를 적용하기위한 Filter를 등록한다.


  <filter>

    <filter-name>springSecurityFilterChain</filter-name>

    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>

  </filter>

  <filter-mapping>

    <filter-name>springSecurityFilterChain</filter-name>

    <url-pattern>/*</url-pattern>

  </filter-mapping>


관련 설정을 저장할 xml파일을 Context에 추가등록한다. 

내껀 Context-* 이기때문에 변경할게 없다.

일부 설명은 발췌


<intercept-url pattern="/login" access="permitAll" />

<intercept-url pattern="/-" access="hasRole('ROLE_USER')"/>

<form-login login-page="/login" username-parameter="username" password-parameter="password" login-processing-url="/authentication" />

 

login-page : 로그인이 요청될 시에 이동할 URL을 설정합니다.

username-parameter : 로그인 아이디의 파라미터명 즉 name필드값을 설정합니다.

passoword-parameter : 비밀번호의 파라미터 명을 설정합니다.

login-processing-url : 폼에서 전송할 URL 값을 설정합니다. (action=login-processing-url)

 

여기서 주의할 점은 로그인 URL 인터셉터를 모든 리소스를 차단하는 인터셉터의 위쪽으로 배치시켜야 한다는 것입니다. 만약 그렇지 않다면 리디렉션 순환 오류로 정상적인 로그인 창이 뜨지 않으실 겁니다

<logout invalidate-session="true" logout-url="/unAuthentication" logout-success-url="/" />


invaldate-session : 세션을 모두 무효로 할 것인지를 사용자에게 묻습니다.

logout-url : 로그아웃 경로를 설정합니다.

logout-seccess-url : 로그아웃이 성공한 뒤에 이동한 경로를 설정합니다.


가장만저 만들어야할게 로그인을 위한 jdbcManager를 만들어줘야한다.

만든다는 개념보다는 상속받아 필요한부분을 추가한다.

기존 org.springframework.security.provisioning.JdbcUserDetailsManager 를 사용하고있었는데

salt관련 처리가 없다 그렇기때문에 SaltedUserDetailsManager 란 클래스를 만들어서 해당클래스를 상속하였다.


public class SaltedUserDetailsManager extends JdbcUserDetailsManager

{

private static final Logger logger = LoggerFactory.getLogger(SaltedUserDetailsManager.class);

    public UserDetails loadUserByUsername(String userId)

    {

        final List<GrantedAuthority> groupAuthorities = super.loadGroupAuthorities(userId);

        for(GrantedAuthority authority : groupAuthorities)

        {

            logger.info("user authority : {} ",authority.getAuthority());

        }


        UserDetails user =  getJdbcTemplate().queryForObject(

                super.getUsersByUsernameQuery(),

                new String[]{userId},

                new RowMapper<UserDetails>(){

                    public UserDetails mapRow(ResultSet rs, int rowNum) throws SQLException

                    {

                        String userId = rs.getString(1);

                        String password = rs.getString(2);

                        boolean enabled = rs.getBoolean(3);

                        String salt = rs.getString(4);

                        logger.info("user id : {} ",userId);

                        logger.info("user pw : {} ",password);

                        logger.info("user useable : {} ",enabled);

                        logger.info("user salt : {} ",salt);

                        return new SaltedUser(userId, password, enabled, true, true, true, groupAuthorities, salt);

                    }

                }

            );

        return user;

    }

}


이러면 기존 org.springframework.security.core.userdetails.User 타입을 반환하게 되있는데 역시 salt가 없다.

당연히 추가해야한다.


public class SaltedUser extends User

{


    private String salt;

    public SaltedUser( String username, 

    String password, 

    boolean enabled, 

    boolean accountNonExpired, 

    boolean credentialsNonExpired, 

    boolean accountNonLocked, 

    Collection<? extends GrantedAuthority> authorities, 

    String salt)

    {

        super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);

        this.salt = salt;

    }


    public String getSalt()

    {

        return salt;

    }

    public void setSalt(String salt)

    {

        this.salt = salt;

    }

}


이거면 로그인에필요한 자바쪽 작업은 끝났다.

context에 bean을 추가해준다.

쿼리는 컬럼명이중요한게 아니라 순서가 중요한거다. 이정돈 알겟지?

사실나는 별생각없이 적용했기때문에 테이블쪽 설계를 안햇다. 그래서 1개테이블로 그룹없고 권한단순하게 일단했다.

근데 enableGroups 옵션을 false해도 자꾸 에러나길래 봣더니 기존 default쿼리를 때리고있었다. 

안써도 일단 추가햇다.


    <bean id="jdbcUserService" class="kr.iwallet.SaltedUserDetailsManager"

        p:dataSource-ref="dataSource"

        p:enableGroups="false"

        p:usersByUsernameQuery="SELECT ID , PWD, ENABLED, SALT FROM USER_TABLE WHERE ID=?"

        p:authoritiesByUsernameQuery="SELECT ID AS USERNAME, ROLE AS AUTHORITY FROM USER_TABLE WHERE ID=?"

        p:groupAuthoritiesByUsernameQuery="SELECT ID , PWD, ENABLED, SALT FROM USER_TABLE WHERE ID=?"

     />


그리고 encoder와 salt쪽 설정을 추가한다.

userPropertyToUse 가 salt 인이유는 소스를 함 열어봐라. 내가위에서 Users를 왜 상속해서 새로만들었는지 알수있다.


<bean id="saltSource" class="org.springframework.security.authentication.dao.ReflectionSaltSource">

<property name="userPropertyToUse" value="salt"/>

</bean>

<bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.ShaPasswordEncoder" />


마지막으로 해당 bean들을 사용할수있게 세팅.


    <security:authentication-manager>

        <security:authentication-provider user-service-ref="jdbcUserService">

            <security:password-encoder ref="passwordEncoder">

                <security:salt-source ref="saltSource"/>

            </security:password-encoder>

        </security:authentication-provider>

    </security:authentication-manager> 

이럼 password와 salt 컬럼의값을 더하고 암호화한값을 db의 password와 비교하게된다.

사용자를 추가하거나 수정할때는 암호화를하고 salt를 넣어야겟지?

salt는 임의의 랜덤한 값을 넣게되는데 나는 생성 수정당시의 시분초를 넣었다.

그래서 이렇게 암호화하면 끝


String encodePassword = passwordEncoder.encodePassword(pw,salt);







 

Posted by 박공명
, |

세상에 공짜보다 좋은게 없으므로

스프링 프레임워크를 사용한 웹페이지에 네이버 스마트 에디터를 적용하도록 하겟다.

사실 에디터 적용은 잭스도 할수있는일이니 사진 퀵 업로더가 주 내용이다.

나는 개발서버에서의 에디터 위치를 /resource/SE 로 설정하였다.

사실 플러그인 설치와 버튼 추가는 설명도 잘 되있을 뿐더러

이미 적용되어 있더라 ㅡ,.ㅡ 손댈것이 없다.

업로드용 javascript를 수정해야한다.

 

/resource/SE/photo_uploder/popup/attach_photo.js

 

callFileUploader 이건 html5를 사용하지않는 업로드용이라는데 이걸 기준으로 해보겠다.

request를 전송할 주소를 만들어준다.

나는 아래와같은 주소로 POST 형식으로 파일을 받을거다.

sCallback은 스프링에서는 지워줘도 될거같다.

놔둬봐야 쓸모업는 페이지 한번 더읽는거같다.

 

sUrl  : 'http://localhost:8080/web/imageUpload.gm'

 

파일업로드를하는데 대체 어디다 담아올릴건지 확인을 안했다.

사진업로드할때 나오는 팝업인 photo_uploader.html 파일을 살펴보면 Filedata 라는 이름을 찾을수 있다.

이 이름으로 파일을 받아서 저장하고해야하며 또 중요한건 파일을 올릴때 별도의 콜백함수이름을 같이 보내준다는거다.

결론은 파일이름,콜백함수명 두개를 화면으로 다시 가져와야한다.

나는 callBack.jsp 를 새로 만들었다.

 


 @RequestMapping(value = "/imageUpload.gm", method = RequestMethod.POST)
 public String writeBoard(Locale locale, Model model,HttpServletRequest request) {
  logger.info("Welcome imageUpload!! The client locale is {}.", locale);
  
  String filename = "";
  String filenameFront = "";
  String filenameExt = "";
  String convFilename = "";
  FileSystemResource uploadDir = new FileSystemResource("E:/APPLICATION/STC/vfabric-tc-server-developer-2.9.3.RELEASE/base-instance/wtpwebapps/gm_spring_mvc/resources/uploadimages/");
  
  MultipartHttpServletRequest multipart = (MultipartHttpServletRequest) request;
  MultipartFile file = multipart.getFile("Filedata");
  String callBack = multipart.getParameter("callback_func");
  if(!file.isEmpty()) {
   
   filename = file.getOriginalFilename();
   filenameFront = filename.substring(filename.lastIndexOf("."));
   filenameExt = filename.substring(filename.lastIndexOf("."),filename.length());
   //convFilename = Tool.getCurrentDayTimeMill() + filenameExt;
   convFilename = "";
   logger.info("OriginalFilename : {}", filename);
   logger.info("OriginalFilename front : {}", filenameFront);
   logger.info("OriginalFilename ext : {}", filenameExt);
   logger.info("uploadDir : {}", uploadDir.getPath());
   
   try {
    if(file.getSize() > 0){
     File out = new File(uploadDir.getPath() + "/" + Tool.getCurrentDayTimeMill() + filenameExt);
     FileCopyUtils.copy(file.getBytes(), out);
     convFilename = out.getName();
     logger.info("ConvertFilename : {}", convFilename);
    }
   } catch (IOException e) {
    e.printStackTrace();
   }
  
  }

  model.addAttribute("filename", convFilename);
  model.addAttribute("callback_func", callBack);

  return "/util/callback";
 }

 

이러면 파일이 저장된 후 파일이름과 콜백함수명을 callBack.jsp로 뱉어준다.

기존 에디터 샘플에있는 callBack.html 을 내jsp경로(/util/)로 옮겨주고 일부 내용만 수정해준다.

 

var oParameter = {callback_func:"${callback_func}",sFileName : "${filename}",sFileURL : "http://localhost:8080/web/resources/uploadimages/${filename}",bNewLine : true }; // query array

 

뭐 더이상의 설명은 생략한다.

결과물.

 

 

 

 

Posted by 박공명
, |

먼저 스프링 환경변수를 추가한다.

속성은 업로드사이즈 20메가 제한만 두었다.

 

<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="20000000"></property>
</bean>

 

두번째 CommonsMultipartResolver 는 스프링 설치시 포함되지 않은 두개의 라이브러리를 요구한다.

 

http://commons.apache.org/proper/commons-io/

http://commons.apache.org/proper/commons-fileupload/

 

세번째 컨트롤러에서 파일업로드를 처리한다.

내경우 실제 운영용서버는 라즈베리파이이며 웹서버가 별개이기때문에 파일경로관련하여 각별히 신경써야한다.

내소스 발췌


 @RequestMapping(value = "/write.gm", method = RequestMethod.POST)
 public String writeBoard(Locale locale, Model model,HttpServletRequest request) {
  logger.info("Welcome board write insert!! The client locale is {}.", locale);
  
  String filename = "";
  String filenameFront = "";
  String filenameExt = "";
  String convFilename = "";
  FileSystemResource uploadDir = new FileSystemResource("E:/APPLICATION/STS/vfabric-tc-server-developer-2.9.3.RELEASE/base-instance/wtpwebapps/gm_spring_mvc/WEB-INF/uploadfiles/");
  //FileSystemResource uploadDir = new FileSystemResource("/var/www/web/uploadfiles/"); //운영시스템용
  MultipartHttpServletRequest multipart = (MultipartHttpServletRequest) request;
  MultipartFile file = multipart.getFile("fileupload");
  
  if(!file.isEmpty()) {
   
   filename = file.getOriginalFilename();
   filenameFront = filename.substring(filename.lastIndexOf("."));
   filenameExt = filename.substring(filename.lastIndexOf("."),filename.length());
   convFilename = "";
   logger.info("OriginalFilename : {}", filename);
   logger.info("OriginalFilename front : {}", filenameFront);
   logger.info("OriginalFilename ext : {}", filenameExt);
   logger.info("uploadDir : {}", uploadDir.getPath());
   
   try {
    if(file.getSize() > 0){
     File out = new File(uploadDir.getPath() + "/" + Tool.getCurrentDayTimeMill() + filenameExt);
     FileCopyUtils.copy(file.getBytes(), out);
     convFilename = out.getName();
     logger.info("ConvertFilename : {}", out.getName());
    }
   } catch (IOException e) {
    e.printStackTrace();
   }
  
  }

  String location = multipart.getParameter("location") == null ? "1" : multipart.getParameter("location");
  String stringPage = multipart.getParameter("page") == null ? "" : multipart.getParameter("page");
  logger.info("location = {} / page = {}", location,stringPage);
  HashMap argument = new HashMap();
  argument.put("title", Tool.encodeHTMLSpecialChar(multipart.getParameter("title"), 2));
  argument.put("writer", Tool.encodeHTMLSpecialChar(multipart.getParameter("writer"), 2));
  argument.put("board_location", location);
  argument.put("content", multipart.getParameter("ir1"));
  argument.put("password", multipart.getParameter("password"));
  argument.put("ori_filename", filename);
  argument.put("filename", convFilename);
  boardService.insertBoard(argument);
  
  model.addAttribute("location", location);

  return board(locale,model,request);
 }

 

마지막으로 화면에서 form 생성시 가장 기본적인 내용.

 

enctype="multipart/form-data"

 

 

 

Posted by 박공명
, |

spring - mybatis 세팅

Dev/linux / 2014. 1. 22. 18:54

가장먼저 라이브러리 업데이트를 해야된다.

maven 요즘 다들 쓰져?

pom.xml에 해당내용을 추가한다.


  <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>3.2.4.RELEASE</version>
  </dependency>
  <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.26</version>
  </dependency>
  <dependency>
      <groupId>com.kenai.nbpwr</groupId>
      <artifactId>org-apache-commons-dbcp</artifactId>
      <version>1.2.2-201002241055</version>
  </dependency>
  <dependency>
     <groupId>org.mybatis</groupId>
     <artifactId>mybatis</artifactId>
     <version>3.2.2</version>
   </dependency>
   <dependency>
     <groupId>org.mybatis</groupId>
     <artifactId>mybatis-spring</artifactId>
     <version>1.2.0</version>
   </dependency>

 

저장하면 자동으로 라이브러리가 업데이트된다.

그후에 mybatis 환경파일을 만든다.

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
  
    <context:component-scan base-package="com.pgmman.webmvc"/>

    <context:property-placeholder location="classpath:jdbc.properties"/>
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${jdbc.driverClassName}"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
    </bean>
 
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="typeAliasesPackage" value="com.pgmman.webmvc.vo"/>
        <property name="mapperLocations" value="classpath*:com/pgmman/webmvc/mapper/*.xml"/>
    </bean>


    <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
        <constructor-arg index="0" ref="sqlSessionFactory"/>
    </bean>
   
 <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
   <property name="dataSource" ref="dataSource"/>
 </bean>
 <tx:annotation-driven transaction-manager="transactionManager" />

</beans>

 

중간에 환경파일이 하나 있을것이다 jdbc.properties 요놈을 생성해준다.

 

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost/gmProject
jdbc.username=비밀

jdbc.password=비밀

 

마지막으로 web.xml 에 해당 환경을 읽도록 추가해준다.

전부 다읽도록 수정했다.

 

 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>
  /WEB-INF/spring/*-context.xml
  </param-value>
 </context-param>

 

테스트해야지.

 

테스트할 쿼리를 user.xml에 생성했다.

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="user">

  <select id="getUserList" resultType="UserInfoVO">
   SELECT user_id,user_name
   FROM user
  </select>

</mapper>

 

dao도 생성한다.

 

@Repository
public class UserInfoDao {

  @Autowired
  private SqlSession sqlSession;

  public List<UserInfoVO> getUserList() {

   return sqlSession.selectList("user.getUserList");

  }

}

 

service생성한다.

 

@Service
public class UserInfoService {

  @Autowired
  private UserInfoDao userInfoDao;

  public List<UserInfoVO> getUserList() {

   return userInfoDao.getUserList();

  }

}

 

Controller생성한다.

@Controller
public class BoardController {
 
 @Autowired
 private UserInfoService userInfoService;

 private static final Logger logger = LoggerFactory.getLogger(BoardController.class);
 
 @RequestMapping(value = "/board.gm", method = RequestMethod.GET)
 public String home(Locale locale, Model model) {
  logger.info("Welcome board!! The client locale is {}.", locale);
  
  Date date = new Date();
  DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
  
  String formattedDate = dateFormat.format(date);
  
  model.addAttribute("serverTime", formattedDate );
  model.addAttribute("userList", userInfoService.getUserList());

  return "board";
 }

}

 

화면 생성한다.

 

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" pageEncoding="utf-8" %>
<%
 //UserInfoVO user;
 //user = request.getAttribute("userList");
%>
<html>
<head>
 <title>Board</title>
</head>
<body>
<h1>
 Hello world! 
</h1>

<P>  The time on the server is ${serverTime}. </P>

    <c:forEach var='user' items='${userList}'>
     ${user.user_id}/${user.user_name}<br>
    </c:forEach>
</body>
</html>

 

자 그럼 보일것이다.

 

 

 

 

끝.

 

Posted by 박공명
, |

일단 설치를 한다

 

apt-get install mysql-server mysql-client

 

설치중에 비밀번호를 입력한다.

설치후에 접속해서 기초적인 설정을 한다.

 

mysql -p

 

암호치고 

 

디비와 유저를 생성해준다.

 

mysql> create database gmproject;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| gmproject          |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.01 sec)

mysql> grant select,insert,update,delete,create,drop,alter on gmproject.* to 'pgmman'@'%' identified by '비밀';
Query OK, 0 rows affected (0.01 sec)

mysql>
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

 

exit로 종료하고

생성한 아뒤로 접속하면된다.

 

root@raspberrypi:/usr/local/apache-tomcat-6.0.37/webapps/web# mysql -u pgmman -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 51
Server version: 5.5.33-0+wheezy1 (Debian)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use gmproject
Database changed

 

자 나는 한단계 더가서

기존 사용하던 디비의 정보를 새로 설치한 서버에 옮기고싶다.

기존 윈도우 시스템에서 백업을 수행한다.

 

E:\APPLICATION\mysql-5.1.48\bin>mysqldump -uroot -p gmproject > gmproject.sql
Enter password: *******

E:\APPLICATION\mysql-5.1.48\bin>dir *.sql
 E 드라이브의 볼륨: MAIN_APP
 볼륨 일련 번호: F862-C7B4

 E:\APPLICATION\mysql-5.1.48\bin 디렉터리

2014-01-22  오후 03:51            13,906 gmproject.sql
               1개 파일              13,906 바이트
               0개 디렉터리  17,593,155,584 바이트 남음

E:\APPLICATION\mysql-5.1.48\bin>

 

전에 설치한 ftp서버를 통하여 백업파일을 업로드한다.

그담에 복원명령어 치면 끝

 

root@raspberrypi:/home/pi# mysql -u root -p gmproject < ./gmproject.sql
Enter password:
root@raspberrypi:/home/pi# mysql -upgmman -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 54
Server version: 5.5.33-0+wheezy1 (Debian)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use gmproject
Database changed
mysql> show tables;
+---------------------+
| Tables_in_gmproject |
+---------------------+
| board               |
| developer           |
| menu                |
| uploadfiles         |
| user                |
+---------------------+
5 rows in set (0.01 sec)

mysql>

정상적으로 들어왔다.
 

Posted by 박공명
, |

java를 설치한다.

 

apt-get install openjdk-7-jdk

 

설치됬다.

 

환경변수를 등록해준다.

 

root@raspberrypi:/usr/lib/jvm# nano /etc/profile

아래 라인을 추가

 

export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-armhf"

그리고 등록 후 확인한다.

 

root@raspberrypi:/usr/lib/jvm# source /etc/profile
root@raspberrypi:/usr/lib/jvm# echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk-armhf

이제 톰캣을 받는다.


root@raspberrypi:/usr/local# wget http://apache.mirror.cdnetworks.com/tomcat/tomcat-6/v6.0.37/bin/apache-tomcat-6.0.37.tar.gz
--2014-01-21 11:12:39--  http://apache.mirror.cdnetworks.com/tomcat/tomcat-6/v6.0.37/bin/apache-tomcat-6.0.37.tar.gz
Resolving apache.mirror.cdnetworks.com (apache.mirror.cdnetworks.com)... 61.110.198.174
Connecting to apache.mirror.cdnetworks.com (apache.mirror.cdnetworks.com)|61.110.198.174|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6885442 (6.6M) [application/x-gzip]
Saving to: `apache-tomcat-6.0.37.tar.gz'

100%[=====================================================================>] 6,885,442   2.06M/s   in 3.2s

2014-01-21 11:12:42 (2.02 MB/s) - `apache-tomcat-6.0.37.tar.gz' saved [6885442/6885442]

 

이제 다운로드받은 톰캣을 압축을 푼다.

 

tar -zxvf apa~(tab누르면 자동완성된다)

 

자동실행되게한다.

 

nano /etc/rc.local

 

아래처럼

 

/usr/local/apache-tomcat-6.0.37/bin/startup.sh

 

이제 아파치를 설치한다.

 

apt-get install apache2

 

apt-get install libapache2-mod-jk

 

환경설정파일을 편집해서 jk module을 사용하도록 추가한다.

 

root@raspberrypi:/etc/apache2# nano apache2.conf

#JK_MODULE
LoadModule jk_module /usr/lib/apache2/modules/mod_jk.s

 

jk module사용하여 넘길 패턴을 설정할수있도록 해당 파일을 수정한다.


root@raspberrypi:/etc/apache2# cd sites-enabled/
root@raspberrypi:/etc/apache2/sites-enabled# ls
000-default
root@raspberrypi:/etc/apache2/sites-enabled# nano 000-default

해당 내용을 추가해 넣는다. 무식하게 똑같이 따라넣는건 아니다.


JkMount /*.jsp ajp13_worker
JkMount /*.gm ajp13_worker

 

로컬호스트에 접속했을떄 It work! 뭐 이런말 뜨면 apache가 정상작동 하고있는상황

로컬호스트/index.jsp 로 접속시 톰캣이 뜨면 연동성공한거다.

요렇게

 

 

 

 

어? 끝!

Posted by 박공명
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함