From 961405426a8e334bbf8310774ec6bed8a4c6b277 Mon Sep 17 00:00:00 2001 From: cholhong Date: Tue, 22 Aug 2017 20:19:20 +0900 Subject: [PATCH] MVC test add --- MVCTest/.classpath | 42 +++ MVCTest/.gitignore | 1 + MVCTest/.project | 49 +++ MVCTest/.settings/.jsdtscope | 13 + .../org.eclipse.core.resources.prefs | 3 + MVCTest/.settings/org.eclipse.jdt.core.prefs | 8 + .../org.eclipse.wst.common.component | 9 + ....eclipse.wst.common.project.facet.core.xml | 8 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.validation.prefs | 2 + MVCTest/pom.xml | 299 ++++++++++++++++++ .../java/lab/web/HelloWorldController.java | 26 ++ .../java/lab/web/PersonServiceController.java | 93 ++++++ .../src/main/java/lab/web/model/person.java | 34 ++ .../META-INF/spring/context-common.xml | 10 + MVCTest/src/main/resources/log4j2.xml | 26 ++ MVCTest/src/main/webapp/META-INF/MANIFEST.MF | 3 + .../config/springmvc/context-servlet.xml | 14 + .../webapp/WEB-INF/jsp/hello/helloworld.jsp | 11 + .../webapp/WEB-INF/jsp/person/personForm.jsp | 23 ++ .../WEB-INF/jsp/person/personSuccess.jsp | 13 + MVCTest/src/main/webapp/WEB-INF/web.xml | 44 +++ MVCTest/src/main/webapp/index.jsp | 21 ++ MVCTest/src/test/java/.gitkeep | 0 MVCTest/src/test/resources/.gitkeep | 0 .../target/m2e-wtp/web-resources/.gitignore | 1 + 27 files changed, 755 insertions(+) create mode 100644 MVCTest/.classpath create mode 100644 MVCTest/.gitignore create mode 100644 MVCTest/.project create mode 100644 MVCTest/.settings/.jsdtscope create mode 100644 MVCTest/.settings/org.eclipse.core.resources.prefs create mode 100644 MVCTest/.settings/org.eclipse.jdt.core.prefs create mode 100644 MVCTest/.settings/org.eclipse.wst.common.component create mode 100644 MVCTest/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 MVCTest/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 MVCTest/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 MVCTest/.settings/org.eclipse.wst.validation.prefs create mode 100644 MVCTest/pom.xml create mode 100644 MVCTest/src/main/java/lab/web/HelloWorldController.java create mode 100644 MVCTest/src/main/java/lab/web/PersonServiceController.java create mode 100644 MVCTest/src/main/java/lab/web/model/person.java create mode 100644 MVCTest/src/main/resources/META-INF/spring/context-common.xml create mode 100644 MVCTest/src/main/resources/log4j2.xml create mode 100644 MVCTest/src/main/webapp/META-INF/MANIFEST.MF create mode 100644 MVCTest/src/main/webapp/WEB-INF/config/springmvc/context-servlet.xml create mode 100644 MVCTest/src/main/webapp/WEB-INF/jsp/hello/helloworld.jsp create mode 100644 MVCTest/src/main/webapp/WEB-INF/jsp/person/personForm.jsp create mode 100644 MVCTest/src/main/webapp/WEB-INF/jsp/person/personSuccess.jsp create mode 100644 MVCTest/src/main/webapp/WEB-INF/web.xml create mode 100644 MVCTest/src/main/webapp/index.jsp create mode 100644 MVCTest/src/test/java/.gitkeep create mode 100644 MVCTest/src/test/resources/.gitkeep create mode 100644 MVCTest/workspaces/workspace-firstbook/MVCTest/target/m2e-wtp/web-resources/.gitignore diff --git a/MVCTest/.classpath b/MVCTest/.classpath new file mode 100644 index 0000000..650c27d --- /dev/null +++ b/MVCTest/.classpath @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MVCTest/.gitignore b/MVCTest/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/MVCTest/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/MVCTest/.project b/MVCTest/.project new file mode 100644 index 0000000..53f0f4d --- /dev/null +++ b/MVCTest/.project @@ -0,0 +1,49 @@ + + + MVCTest + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + org.springframework.ide.eclipse.core.springnature + egovframework.dev.imp.ide.natures.egovnature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/MVCTest/.settings/.jsdtscope b/MVCTest/.settings/.jsdtscope new file mode 100644 index 0000000..e945e4e --- /dev/null +++ b/MVCTest/.settings/.jsdtscope @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/MVCTest/.settings/org.eclipse.core.resources.prefs b/MVCTest/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..2e67b95 --- /dev/null +++ b/MVCTest/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 diff --git a/MVCTest/.settings/org.eclipse.jdt.core.prefs b/MVCTest/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..c788ee3 --- /dev/null +++ b/MVCTest/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/MVCTest/.settings/org.eclipse.wst.common.component b/MVCTest/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..2b45459 --- /dev/null +++ b/MVCTest/.settings/org.eclipse.wst.common.component @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/MVCTest/.settings/org.eclipse.wst.common.project.facet.core.xml b/MVCTest/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..dc2b7dc --- /dev/null +++ b/MVCTest/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/MVCTest/.settings/org.eclipse.wst.jsdt.ui.superType.container b/MVCTest/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..3bd5d0a --- /dev/null +++ b/MVCTest/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/MVCTest/.settings/org.eclipse.wst.jsdt.ui.superType.name b/MVCTest/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..05bd71b --- /dev/null +++ b/MVCTest/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/MVCTest/.settings/org.eclipse.wst.validation.prefs b/MVCTest/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 0000000..6f1cba6 --- /dev/null +++ b/MVCTest/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,2 @@ +disabled=06target +eclipse.preferences.version=1 diff --git a/MVCTest/pom.xml b/MVCTest/pom.xml new file mode 100644 index 0000000..c6eabf4 --- /dev/null +++ b/MVCTest/pom.xml @@ -0,0 +1,299 @@ + + + 4.0.0 + lab + MVCTest + war + 1.0.0 + MVCTest + http://www.egovframe.go.kr + + + 4.1.2.RELEASE + 3.6.0 + + + + + mvn2 + http://repo1.maven.org/maven2/ + + true + + + true + + + + egovframe + http://www.egovframe.go.kr/maven/ + + true + + + false + + + + egovframe2 + http://maven.egovframe.kr:8080/maven/ + + true + + + false + + + + + + + + egovframework.rte + egovframework.rte.ptl.mvc + ${egovframework.rte.version} + + + commons-logging + commons-logging + + + + + egovframework.rte + egovframework.rte.psl.dataaccess + ${egovframework.rte.version} + + + egovframework.rte + egovframework.rte.fdl.idgnr + ${egovframework.rte.version} + + + egovframework.rte + egovframework.rte.fdl.property + ${egovframework.rte.version} + + + + javax.servlet + servlet-api + provided + 2.5 + + + + javax.servlet + jstl + 1.2 + + + + commons-dbcp + commons-dbcp + 1.4 + + + + taglibs + standard + 1.1.2 + + + + org.hsqldb + hsqldb + 2.3.2 + + + + org.antlr + antlr + 3.5 + + + + + + install + ${basedir}/target + ${artifactId}-${version} + + + + org.apache.tomcat.maven + tomcat7-maven-plugin + 2.2 + + 80 + / + + -Xms256m -Xmx768m -XX:MaxPermSize=256m + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.7 + 1.7 + UTF-8 + + + + org.codehaus.mojo + hibernate3-maven-plugin + 2.1 + + + + hbm2ddl + annotationconfiguration + + + + + + org.hsqldb + hsqldb + 2.3.2 + + + + + + org.codehaus.mojo + emma-maven-plugin + 1.0-alpha-3 + + + + org.apache.maven.plugins + maven-pmd-plugin + 3.1 + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + once + xml + + **/Abstract*.java + **/*Suite.java + + + **/*Test.java + + + + + org.codehaus.mojo + emma-maven-plugin + true + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + + + ${basedir}/target/site + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.7 + + + sunlink + + javadoc + + true + + + http://docs.oracle.com/javase/6/docs/api/ + + + + + + + + org.codehaus.mojo + emma-maven-plugin + true + + + org.codehaus.mojo + surefire-report-maven-plugin + true + + + + report-only + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + 128m + 512m + ${encoding} + ${encoding} + ${encoding} + + + + + org.apache.maven.plugins + maven-jxr-plugin + + ${encoding} + ${encoding} + true + apidocs + + + + + diff --git a/MVCTest/src/main/java/lab/web/HelloWorldController.java b/MVCTest/src/main/java/lab/web/HelloWorldController.java new file mode 100644 index 0000000..2721846 --- /dev/null +++ b/MVCTest/src/main/java/lab/web/HelloWorldController.java @@ -0,0 +1,26 @@ +package lab.web; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +@Controller +public class HelloWorldController { + + private String viewName = "hello/helloworld"; + + public String getViewName(){ + return this.viewName; + } + + @RequestMapping(value = "/hello.do") + public String helloworld() { + return getViewName(); + } + + @RequestMapping(value = "/hello2.do") + public ModelAndView helloworld2() { + ModelAndView mav = new ModelAndView(viewName); + return mav; + } +} diff --git a/MVCTest/src/main/java/lab/web/PersonServiceController.java b/MVCTest/src/main/java/lab/web/PersonServiceController.java new file mode 100644 index 0000000..daead78 --- /dev/null +++ b/MVCTest/src/main/java/lab/web/PersonServiceController.java @@ -0,0 +1,93 @@ +package lab.web; + +import java.util.Iterator; +import java.util.Map; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +import egovframework.rte.ptl.mvc.bind.annotation.CommandMap; +import lab.web.model.person; + +@Controller +public class PersonServiceController { + + private String formView = "person/personForm"; + private String successView = "person/personSuccess"; + Logger logger1 = LogManager.getLogger(PersonServiceController.class.getName()); + + @RequestMapping(value = "/person.do", method=RequestMethod.GET) + protected String personInput(ModelMap model) throws Exception{ + model.addAttribute("personinfo",new person()); + return formView; + } + + @RequestMapping(value = "/person.do", method=RequestMethod.POST) + protected String regist(@RequestParam Map commandMap, person command, +// protected String regist(person command, + BindingResult errors, ModelMap model) throws Exception { + if (errors.hasErrors()) { + return formView; + } +// logger1.debug("name="+command.getName()); + Iterator mapIter = commandMap.keySet().iterator(); + while(mapIter.hasNext()){ + String key = mapIter.next(); + Object value = commandMap.get( key ); + logger1.debug(key+" : "+value); + } + + model.addAttribute("pinfo",command); + return successView; + } + + @RequestMapping(value = "/person2.do", method=RequestMethod.GET) + protected String personInput2(ModelMap model) throws Exception{ + model.addAttribute("personinfo",new person()); + return formView; + } + + @RequestMapping(value = "/person2.do", method=RequestMethod.POST) + protected String regist2(@RequestParam("name") String name, + @RequestParam(value="company", required=false) String company, + @RequestParam(value="phone", required=false) String phone, + @RequestParam(value="email", required=false) String email, + ModelMap model) throws Exception { + person personinfo = new person(); + personinfo.setName(name); + personinfo.setCompany(company); + personinfo.setPhone(phone); + personinfo.setEmail(email); + + model.addAttribute("pinfo",personinfo); + return successView; + } + + @RequestMapping(value = "/person3.do", method=RequestMethod.GET) + protected String personInput3(ModelMap model) throws Exception{ + person pobject = new person(); + pobject.setName("KIM"); + pobject.setCompany("company"); + pobject.setPhone("02-1234-5948"); + pobject.setEmail("abc@email.com"); + model.addAttribute("personinfo",pobject); + return formView; + } + + @RequestMapping(value = "/person3.do", method=RequestMethod.POST) + protected String regist3(@ModelAttribute("personinfo") person command, + BindingResult errors, ModelMap model) throws Exception { + if (errors.hasErrors()) { + return formView; + } + model.addAttribute("pinfo",command); + return successView; + } +} diff --git a/MVCTest/src/main/java/lab/web/model/person.java b/MVCTest/src/main/java/lab/web/model/person.java new file mode 100644 index 0000000..33ad4c6 --- /dev/null +++ b/MVCTest/src/main/java/lab/web/model/person.java @@ -0,0 +1,34 @@ +package lab.web.model; + +public class person { + + private String name; + private String company; + private String phone; + private String email; + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getCompany() { + return company; + } + public void setCompany(String company) { + this.company = company; + } + public String getPhone() { + return phone; + } + public void setPhone(String phone) { + this.phone = phone; + } + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } +} diff --git a/MVCTest/src/main/resources/META-INF/spring/context-common.xml b/MVCTest/src/main/resources/META-INF/spring/context-common.xml new file mode 100644 index 0000000..ad920bc --- /dev/null +++ b/MVCTest/src/main/resources/META-INF/spring/context-common.xml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/MVCTest/src/main/resources/log4j2.xml b/MVCTest/src/main/resources/log4j2.xml new file mode 100644 index 0000000..bd765b9 --- /dev/null +++ b/MVCTest/src/main/resources/log4j2.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MVCTest/src/main/webapp/META-INF/MANIFEST.MF b/MVCTest/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 0000000..5e94951 --- /dev/null +++ b/MVCTest/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/MVCTest/src/main/webapp/WEB-INF/config/springmvc/context-servlet.xml b/MVCTest/src/main/webapp/WEB-INF/config/springmvc/context-servlet.xml new file mode 100644 index 0000000..9f0eb4c --- /dev/null +++ b/MVCTest/src/main/webapp/WEB-INF/config/springmvc/context-servlet.xml @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/MVCTest/src/main/webapp/WEB-INF/jsp/hello/helloworld.jsp b/MVCTest/src/main/webapp/WEB-INF/jsp/hello/helloworld.jsp new file mode 100644 index 0000000..4619b78 --- /dev/null +++ b/MVCTest/src/main/webapp/WEB-INF/jsp/hello/helloworld.jsp @@ -0,0 +1,11 @@ +<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> + + + + +Hello + + +

Hello SW Framework

+ + \ No newline at end of file diff --git a/MVCTest/src/main/webapp/WEB-INF/jsp/person/personForm.jsp b/MVCTest/src/main/webapp/WEB-INF/jsp/person/personForm.jsp new file mode 100644 index 0000000..7ee4f50 --- /dev/null +++ b/MVCTest/src/main/webapp/WEB-INF/jsp/person/personForm.jsp @@ -0,0 +1,23 @@ +<%@ page contentType="text/html; charset=UTF-8"%> +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> + + + + +사원정보 + + +

사원정보

+ +
NAME : +

+
COMPANY : +

+
PHONE : +

+
EMAIL : +

+
+
+ + \ No newline at end of file diff --git a/MVCTest/src/main/webapp/WEB-INF/jsp/person/personSuccess.jsp b/MVCTest/src/main/webapp/WEB-INF/jsp/person/personSuccess.jsp new file mode 100644 index 0000000..29b2c26 --- /dev/null +++ b/MVCTest/src/main/webapp/WEB-INF/jsp/person/personSuccess.jsp @@ -0,0 +1,13 @@ +<%@ page contentType="text/html; charset=UTF-8"%> + + + +사원정보 + + +
NAME: ${pinfo.name}
+
COMPANY: ${pinfo.company}
+
PHONE: ${pinfo.phone}
+
EMAIL: ${pinfo.email}
+ + \ No newline at end of file diff --git a/MVCTest/src/main/webapp/WEB-INF/web.xml b/MVCTest/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..a3c12dc --- /dev/null +++ b/MVCTest/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,44 @@ + + + + + + encodingFilter + org.springframework.web.filter.CharacterEncodingFilter + + encoding + utf-8 + + + + + encodingFilter + *.do + + + + + contextConfigLocation + classpath*:META-INF/spring/context-*.xml + + + + org.springframework.web.context.ContextLoaderListener + + + + + mvcAction + org.springframework.web.servlet.DispatcherServlet + + contextConfigLocation + /WEB-INF/config/springmvc/context-*.xml + + 1 + + + + mvcAction + *.do + + \ No newline at end of file diff --git a/MVCTest/src/main/webapp/index.jsp b/MVCTest/src/main/webapp/index.jsp new file mode 100644 index 0000000..96993b0 --- /dev/null +++ b/MVCTest/src/main/webapp/index.jsp @@ -0,0 +1,21 @@ +<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> + + + + +MVC + + + + + \ No newline at end of file diff --git a/MVCTest/src/test/java/.gitkeep b/MVCTest/src/test/java/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/MVCTest/src/test/resources/.gitkeep b/MVCTest/src/test/resources/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/MVCTest/workspaces/workspace-firstbook/MVCTest/target/m2e-wtp/web-resources/.gitignore b/MVCTest/workspaces/workspace-firstbook/MVCTest/target/m2e-wtp/web-resources/.gitignore new file mode 100644 index 0000000..3385916 --- /dev/null +++ b/MVCTest/workspaces/workspace-firstbook/MVCTest/target/m2e-wtp/web-resources/.gitignore @@ -0,0 +1 @@ +/META-INF/