Hello, all

 

I want to use struts2.0.14 but I’m a beginner.

I want to return xml to the browser, If I return null in the execute method
of an action, is there any ban consequence? I need some advice.

I just want it this way:

 

In my action:

public String execute() throws Exception{

 

PrintWriter pw = null;

response.setContentType(“text/xml;charset=GBK”);

reponse.setHeader(“Cache-Control”, “no-cache”);

try{

                  pw = response.getWriter();

                  pw.print(“<root><child>Lucy</child></root>”);

} catch (IOException e) {

                  e.printStackTrace();

} finally {

                  pw.close();

                  pw = null;

}

 

return null;

 

}

 

 

Reply via email to