Hi,
I'm just wondering what the best way would be to organize content delivery in a scenario where we have
* An HTML website
* A mobile website
* A PhoneGap app that supports HTML pushState and works of json
The important thing for me is to have a flexible url structure and minimal coding to support all options. I was thinking something like this
Any suggestions?PHP Code:/**
* Displays a normal HTML page
*/
@Controller
@RequestMapping("/path")
public class StuffController{
@Inject
ItemManager itemMgr;
public void insertCommonContent(ModelMap model){
model.addAttribute("items", itemMgr.getItems());
}
@RequestMapping("/stuff", method=RequestMethod.GET)
public String getStuff(ModelMap model){
insertCommonContent(model);
model.addAttribute("pageTitle", "Hello there");
model.addAttribute("specialOffers", getSpecialOffers());
}
}
/**
* Returns json
*/
@Controller
public class JsonStuffController extends StuffController{
@RequestMapping("/stuff.json", method=RequestMethod.GET)
public @ResponseBody Map<String,Object> getStuff(ModelMap model){
Map<String,Object> resp = new HashMap<String,Object>();
resp.add("items", itemMgr.getItems());
return resp;
}
}
/**
* Displays an HTML page optimized for mobile
*/
@Controller
@RequestMapping("/path/mobile")
public class MobileStuffController extends StuffController{
@RequestMapping("/stuff", method=RequestMethod.GET)
public String getStuff(ModelMap model){
insertCommonContent(model);
}
}
Marc


Reply With Quote