//返回值为null,可以直接输出纯文本
public String doSomeAction() {
response.setContentType("text/html; charset=utf-8");
PrintWriter
pw
= response.getWriter();
pw.write( "testtestsetsetsetsetset" );
pw.flush();
pw.close();
return
null;
}
//返回值为null,可以执行完action后直接转向
public
String doSomeAction() {
response.sendRedirect(" http://www.baidu.com ");
return
null;
}
本文提供了一个Java方法示例,该方法执行特定操作并返回null。通过设置响应类型为text/html;charset=utf-8,使用PrintWriter进行输出,并在方法结束时返回null。同时展示了如何通过redirect方式直接转向另一个URL。
1261

被折叠的 条评论
为什么被折叠?



