0
我寫客戶端web JSP頁面就好像有一個表格(獲取)與用戶名搜索文本框和提交按鈕支柱2其餘插件客戶端程序
當用戶提交它返回的用戶
JSON格式但是URL看起來像當我提交
http://myhost.net:8080?user=pavan&method.execute=submit 如何我這個網址在Struts2轉換爲以下之一。
http://myhost.net:8080/user/pavan
有在Struts2
@Results({ @Result(name = "success", type = "redirectAction") })
public class UsersController implements ModelDriven<Object>,
ServletRequestAware {
private String username;
private HttpServletRequest request;
private String representation;
// GET /users/{username}
public HttpHeaders show() {
String acceptHeader = request.getHeader("Accept");
String type = "xml";
if (acceptHeader == null || acceptHeader.isEmpty() ||
acceptHeader.equals("application/xml")) {
representation = UserBO.getXML(username);
} else if (acceptHeader.equals("application/json")) {
representation = UserBO.getJSON(username);
type = "json";
}
return new DefaultHttpHeaders(type).disableCaching();
}