키패드 기능은 InputMethodManager객체를 이용해서 다룰 수 있다. EditText에 포커스를 하면 자동으로 키패드가 뜨는데 inputType이라는 속성 값을 부여함으로써 다른 모드의 키패드를 불러 올 수있다. 다음은 inputType의 대표적 속성이다.inputType 속성값 설 명 number 숫자 numberSigned 0보다 큰 숫자 numberDecimal 정수 text 일반 텍스트 textPassword 패스워드 표시 textEmalAddress 이메일 표시 phone 전화번호 표시 time 시간 date 날짜 layout.xml12345678910111213141516171819202122232425262728293031 Colored by Color Scriptercs activ..
+메이븐 설정1234567891011121314151617 org.springframework spring-websocket ${org.springframework-version} org.springframework spring-messaging ${org.springframework-version} com.fasterxml.jackson.core jackson-databind 2.2.3Colored by Color Scriptercs +웹소켓 요청에 대한 핸들러 작성12345678910111213141516171819202122232425262728293031323334353637383940414243@Componentpublic class ContentHandler extends TextWebSock..
@MVC는 애노테이션 기반의 컨트롤러 기술이다.@MVC 이전의 컨트롤러는 타입을 비교해서 컨트롤러를 선택하고, 그 타입의 구현된 메서드를 호출하는 방법을 사용했다면, @MVC는 @RequestMapping을 이용해서 컨트롤러 클래스나 메서드를 선택하여 호출하는 방법을 사용한다. 이것을 사용하기 위해서는 DefaultAnnotationHandlerMapping을 사용해야 했지만 스프링 3.2부터 deprecated되었고, RequestMappingHandlerMapping가 대신한다. RequestMappingHandlerMapping는 기본적으로 등록되는 빈이라 등록해줄 필요가 없지만 만약 다른 핸들러 매핑 빈을 사용하고 있다면 수동으로 서블릿 컨테이너에 이 빈을 등록해줘야 사용할 수 있다. @Reque..
컨트롤러 스프링에서는 컨트롤러의 유연한 개발을 위해 컨트롤러가 될 수 있는 대상에 대해 제한을 두고 있지 않는다. 스프링은 사용자의 모든 요청이 DispatcherServlet(web.xml에 서블릿으로 정의되어 있음)을 거친다. 직접 컨트롤러 클래스를 작성하기 위해서는 스프링 MVC가 지원하는 컨트롤러를 구현해야 하고 DispatcherServlet에 연결해주는 컨트롤러 어댑터가 필요하다. Servlet, SimpleServletHandlerAdapter이 컨트롤러와 컨트롤러 어댑터는 기존 표준 서블릿(HttpSErvlet을 상속받아 정의하는 서블릿) 클래스 코드를 그대로 유지하면서 사용할 수 있도록한다. HttpRequestHandler, HttpRequestHandlerAdapter이 컨트롤러와 어..
초기화 메서드는 빈 객체가 생성되고 의존관계 주입이 끝난 시점에 실행되는 메서드를 말한다. 생성자에서 초기화 작업을 해도 되지만 빈에서 주입받는 모든 의존관계 변수나 프로퍼티의 DI 작업이 끝난 시점 이후에 초기화를 해야 될 때 초기화 메서드를 사용한다. 초기화 메서드를 지정하는 방법 init-method속성을 xml에 빈 선언시에 지정@PostConstruct init-method속성을 xml 빈 선언시 지정1cs빈 정의시에 init-method 속성에 DI작업이 끝난 이후에 호출될 메서드를 선언해준다. 123456789101112131415161718@Controllerpublic class TestTwoController { CarInfoProvider car; @Resource(name="kiaC..
스프링은 싱글톤(singgleton), 프로토타입(prototype), 요청(request), 세션(session), 글로벌세션(globalSession), 애플리케이션(application) 스코프를 기본적으로 제공 스프링에서 별도의 설정 없이 등록한 빈은 모두 싱글톤 빈이다. 요청 스코프 빈이 빈은 하나의 사용자 웹 요청 안에서 만들어지고 요청이 끝나면 제거된다.각 요청별로 독립적인 빈이 만들어지기 때문에 빈 객체 내에 상태유지 값을 저장해 두어도 안전하다.동시에 많은 요청이 있더라도 각각 별도의 요청 스코프 빈이 만들어지기 때문에 안전하다. +리퀘스트 스코프 빈 모델 객체123456789101112131415@Component@Scope("request")public class RequestScop..
기본적으로 스프링에서 빈을 등록하면 싱글톤으로 만들어진다. 애플리케이션 컨텍스트 마다 빈은 한개씩만 만들어진다는 얘기다.사용자의 요청이 있을 때마다 매번 관련 있는 빈을 새로 생성하는 것은 비효율적이기 때문이다. 싱글톤 빈은 의존성 주입(DI)을 하든지 ApplicationContext를 이용해서 빈을 불어와도 매번 같은 객체를 반환한다. 그런데 때로는 빈을 싱글톤이 아닌 하나의 빈으로 여러개의 객체를 만들어 사용해야 할 때가 있다.그럴 때 프로토 타입 빈을 사용하는데 프로토타입 빈은 컨테이너에게 빈을 요청할 때마다 매번 새로운 객체를 생성하여 반환해준다. 싱글톤빈은 다음과 같이 애노테이션으로 설정할 수 있다.12345678910111213@Component@Scope("prototype")public ..
XML에서 빈을 등록했다면 생성자나 자바빈 규약에 따른 수정자(set으로 시작하는 메서드)에 의존관계 빈이나 값을 주입할 수 있다. 1234567891011public class InjectionTest { public InjectionTest(String name, int age, String s) { System.out.println(name + "======" + age + "=========" + s.toString()); } public void setParameterSetting(String a) { System.out.println(a); } }Colored by Color Scriptercs 123456789 Colored by Color Scriptercs스프링 컨텍스트 XML설정 파일에..
스프링에선 객체의 생성과 사용 및 제거 등의 작업을 애플리케이션 소스코드 대신 독립된 컨테이너가 담당한다. 이것을 IoC(제어역전)라고 부르며, 스프링 컨테이너를 IoC컨테이너라고 부른다. IoC컨테이너의 기본적인 역할코드를 대신해서 애플리케이션을 구현하는 오브젝트를 생성하고 관리하는 것 xml문서, 자바코드, 애노테이션 같은 리소스를 통해서 BeanDefinition 인터페이스 타입으로 변환되어져 이 타입을 IoC컨테이너가 활용한다.BeanDefinition에는 bean하나를 만드는데 필요한 여러 가지 정보가 들어있다. bean 등록 방법은 빈에 필요한 메타정보를 작성해서 컨테이너에 설정하면 된다.가장 직접적인 방법은 BeanDefinition타입의 인터페이스를 구현하는 클래스를 직접 생성하는 것이다...
탭을 사용하면 한 화면에서 서로 다른 두가지 화면의 정보를 전환하면서 보여줄 수 있다. 먼저 com.android.support.design라이브러리를 추가한다. File탭 - project structure - app - dependencies에서 (+)추가 버튼을 누른다. 그리고 Library dependency선택 후 해당 라이브러리를 추가한다. 메인 xml파일을 작성한다.12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 Colored by Color Scriptercs 탭을 사용하는 것은 한 액티비비에서 화면이 전..
상태를 표시해주는 Seekbar는 ProgressBar를 확장한 것이다. ProgressBar의 속성을 가지고 있으면서도 사용자가 이 SeekBar의 값을 조절할 수 있도록 하고 있다. 주로 볼륨 조절이나, 동영상 재생 시에 재생 위치 조절을 위해 사용된다. SeekBar클래스의 setOnSeekBarChangeListener메서드를 통해 SeekBar.OnSeekBarChangeListener를 구현한 클래스를 메서드의 인자로 등록해서 SeekBar의 상태가 바뀔 때마다 호출되도록 할 수 있는 기능을 작성할 수 있다. 액티비티 codepublic class MainActivity extends AppCompatActivity { SeekBar bar; @Override protected void onC..
스프링 시큐리티를 사용한다.ajax로 요청하는 어떤 url(별칭A)로의 접근을 시큐리티가 로그인 한 사용자만 접근하도록 제한하고 있다.한 페이지에서 장시간 사용하지 않아 세션이 만료되어 로그아웃 되었다.하지만 페이지는 로그인한 페이지 그대로 보여 A로 접근하는 ajax를 실행했지만 실패한다.. 이런 이유로다음과 같은 상황에서 ajax를 실행하면 로그인 화면으로 리다이렉트 하도록 한다. 필터클래스를 구현한 bean을 등록하고, security:http엘리먼트 하위에 custom-filter엘리먼트를 등록한다. ..... ..... Colored by Color Scriptercs 필터 클래스의 구현체인 AjaxSessionTimeoutFilter클래스를 만든다.public class AjaxSessionT..
Stream을 사용하면 배열, 컬렉션 클래스 또는 파일에 저장된 데이터들을 같은 방식으로 접근하고 다룰 수 있다. ex) 컬렉션 클래스와 배열을 스트림으로 선언 ArrayList list = new ArrayList(); list.add("전북"); list.add("익산시"); list.add("신동"); list.add("영등동"); list.add("부송동"); Stream stream = list.stream(); //컬렉션 클래스를 스트림으로 선언하는법 //2번째 요소까지만 출력 stream.limit(2).forEach(System.out::println); int[] arr = {1,2,3}; IntStream iStream = Arrays.stream(arr); //배열을 스트림으로 선언하..
현재 지정된 단축 명령 확인#aliascs alias 등록 방법명령행에서 바로 등록(재 접속시 더이상 사용할 수 없다.)#alias remove='rm -rf'cs 현재 사용자만 사용하도록 등록vi ~/.bash_profile #파일이 열리면..아래 명령을 적절한 위치에 등록 alias remove='rm -rf' #저장하고 나와서 source ~/.bashrccs로그아웃 후 재접속을 해야 등록한 alias사용가능 모든 사용자가 사용하도록 등록위의 ~/.bash_profile파일 대신에 /etc/profile파일에 명령어 등록역시 재접속을 해야 사용가능