Java 将JQuery移动组件与spring结合
目前,我使用JQuery Mobile创建一个web移动应用程序。我在此文件中创建了一个具有不同领域的表单:Java 将JQuery移动组件与spring结合,java,jquery,spring,jquery-mobile,spring-mvc,Java,Jquery,Spring,Jquery Mobile,Spring Mvc,目前,我使用JQuery Mobile创建一个web移动应用程序。我在此文件中创建了一个具有不同领域的表单: <body> ... <div data-role="page" data-ajax="false" id="page1"> <jsp:include page="header.jsp"></jsp:include> <div data-role="content">
<body>
...
<div data-role="page" data-ajax="false" id="page1">
<jsp:include page="header.jsp"></jsp:include>
<div data-role="content">
<form id="myForm" method ="post" action="/Address" data-ajax="false">
<input name="streetName" id="streetName" placeholder="<spring:message code="streetName" />" value="" type="text">
<input name="streetNumber" id="streetNumber" placeholder="<spring:message code="streetNumber" />" value="" type="text">
<input name="zipCode" id="zipCode" placeholder="<spring:message code="zipCode" />" value="" type="text">
<input name="city" id="city" placeHolder="<spring:message code="city" />" value="" type="text">
<select name="select-country" id="country">
<option selected="selected" value="select a country">
<spring:message code="selectCountry" />
</option>
<%
String[] locales = LocaleContextHolder.getLocale().getISOCountries();
List<String> countryList = new ArrayList<String>();
for(String countryCode : locales){
Locale loc = new Locale("",countryCode);
countryList.add(loc.getDisplayCountry());
}
Collections.sort(countryList);
for(String country : countryList){
%>
<option value=<%= country %>>
<%= country %>
</option>
<% } %>
</select>
<a id="validationBtn" data-role="button" data-theme="b" data-rel="dialog" data-ajax="false"><spring:message code="adressValidateBtn" /></a>
</form>
</div>
</div>
<div data-role="dialog" id="dialog">
<div data-role="header" data-theme="b">
<h1><spring:message code="errorDetailsDialog" /></h1>
</div>
<div data-role="content" id="text">
</div>
</div>
</body>
当我阅读有关spring的文章时,我发现它存在一些spring组件,因此每个字段都可能代表我的数据模型的一个字段,例如address.streetName、address.streetNumber等等,。。。但我可能不会使用spring组件,因为我为智能手机创建了一个web移动应用程序
此外,如果在数据检查时存在任何错误,我希望通过使用“errors”对象和标记将用户重定向到我的对话框(见第一个示例中的上文)
我想继续使用spring框架和jquery mobile。最好的选择是什么?你的解决方案是什么
多谢各位
@Controller
public class AddressController {
@RequestMapping(value="/address",method=RequestMethod.GET)
public ModelAndView init(){
return new ModelAndView("address");
}
@RequestMapping(value="/address/{streetName}/{streetNumber}/{zipCode}/{city}/{country}")
public ModelAndView validate(
@RequestParam(value="streetName",required = true) String streetName,
@RequestParam(value="streetNumber",required=true) String streetNumber,
@RequestParam(value="zipCode",required = true) String zipCode,
@RequestParam(value="city",required = true) String city,
@RequestParam(value="country",required = true) String country
){
//Control, check-up datas
}}