티스토리 뷰

egovframework 3.5의  Enterprise business 템플릿 프로젝트로 생성한 소스 기준


>>  web.xml 수정

    <servlet>

        <servlet-name>action</servlet-name>

        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

        <init-param>

            <param-name>contextConfigLocation</param-name>

            <param-value>/WEB-INF/config/egovframework/springmvc/*.xml</param-value>

        </init-param>

        <load-on-startup>1</load-on-startup>

    </servlet>

    <servlet-mapping>

        <servlet-name>action</servlet-name>

        <!-- 

        <url-pattern>*.do</url-pattern>

         -->

        <url-pattern>/</url-pattern><!-- restful -->

    </servlet-mapping>


>> egov-com-servlet.xml 수정

   <!-- 

    <mvc:annotation-driven/>

     -->

    <!-- restful -->

      <mvc:annotation-driven  content-negotiation-manager="contentNegotiationManager" /> 

<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">

<property name="favorPathExtension" value="false" />

     <property name="favorParameter" value="true" />

      <property name="mediaTypes" >

    <value>

        json=application/json

           xml=application/xml

       </value>

      </property>

      </bean>


     <!-- restful. 일반 Controller Annotation 사용시 -->

     <mvc:resources mapping="/css/**" location="/css/" />

     <mvc:resources mapping="/html/**" location="/html/" />

     <mvc:resources mapping="/images/**" location="/images/" />

     <mvc:resources mapping="/js/**" location="/js/" />



>> pom.xml 수정

> 아래 dependency 있다면 삭제

<dependency>
    
<groupId>org.codehaus.jackson</groupId>
    
<artifactId>jackson-core-asl</artifactId>
    
<version>1.9.13</version>
</dependency>
<dependency>
    
<groupId>org.codehaus.jackson</groupId>
    
<artifactId>jackson-mapper-asl</artifactId>
    
<version>1.9.13</version>
</dependency>


jackson-jaxrs-base dependency 추가

<dependency>
    
<groupId>com.fasterxml.jackson.jaxrs</groupId>
    
<artifactId>jackson-jaxrs-base</artifactId>
    
<version>2.4.4</version>
</dependency>


>> Controller 예제

@RestController

@RequestMapping("/employees")

public class EmployeeController {

@Resource

EmployeeService employeeService;

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

public List<Employee> selectEmployeeList(@PathVariable("employeeId") String employeeId) throws Exception{

EmployeeSearch search = new EmployeeSearch();

return employeeService.selectEmployeeList(search);

}

}


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/01   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31