0

Convert RequestMapping Spring to Rest Zest

asked 2021-09-21 16:16:43 +0800

onsir gravatar image onsir
132 2

I have a method like this, namely the Restful WebService method to receive data sent in the form of JSON data from the Client. then how to change this method in Restful ZK using zest

i use library zcommons-el.jar zest-2.0.0.FL.20130205.jar

file zest.xml

 <xel-method prefix="c" name="listSalesmanCol" 
    class="org.zkoss.zest.examples.rest.SalesmanRESTController"
    signature="java.lang.String toMethodName(java.lang.String)"/>
<action path="/rest" method="${c:toMethodName(request.method)}" 
            class="org.zkoss.zest.examples.rest.SalesmanRESTController">
    <result>/WEB-INF/rest/RESTfulView.jsp</result>
</action>

file SalesmanRESTController.java this method i want convert Rest using zest

@RequestMapping(value = "/salesman/listSalesmanCol", method = RequestMethod.POST, produces = "application/json")
public void postListSalesmanCol(@RequestBody String strJSONSalesmanCol)throws JsonParseException, JsonMappingException, IOException {
    try {
               Gson gson = new Gson();
               Type type = new TypeToken<List<SalesmanColBean>>() {}.getType();
           List<SalesmanColBean> salesmanColBeanList = gson.fromJson(strJSONSalesmanCol,type);
           for (SalesmanColBean salesmanCol : salesmanColBeanList) {
                System.out.println("salesman.custName() = " + salesmanCol.getCustName());
           }
    }catch(Exception e) {
        e.printStackTrace();
    }
}

thanks

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-09-22 18:04:53 +0800

hawk gravatar image hawk
3250 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2021-09-22 18:33:23 +0800

You can tell the timestamp from its file name that ZEST is not actively maintained for a long time, so we don't suggest to use it.

If you can share some details of your requirements or intentions, we may be able to suggest an alternative.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2021-09-21 16:16:43 +0800

Seen: 6 times

Last updated: Sep 22 '21

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More