我有一个包含两个<select>标签的表单。一个是年份列表,另一个是剂量列表。
当我选择选项时selectedYear,我可以使用 ng-model 在我的控制器中获取,但无法获取selectedDosage. 当我试图将此数据发送到我的 servlet 时,它返回 null 作为值。
我感谢 JSON 的任何建议
Dosages:[
{"name":"Tablet"},
{"name":"Syrups and Suspension"},
{"name":"Non-Antibiotic Capsules"},
{"name":"Antibiotic Capsules"},
{"name":"Dry Powder for Suspension"},
{"name":"ORS"},
{"name":"Antiseptics"}
]
Years:{"json1":"[
{\"years\":2018},
{\"years\":2017},
{\"years\":2016},
{\"years\":2015}]"
HTML
<form ng-submit="Display()">
<select class="form-control" ng-model="selectedYear">
<option value="" selected disabled>Select Year</option>
<option ng-repeat="option in years" ng-value="{{option.years}}" >
{{option.years}}
</option>
</select>
<br>
<select class="form-control" ng-model="selectedDo">
<option value="" selected disabled>Select Dosage</option>
<option ng-repeat="option in section" ng-value="{{option.name}}" >
{{option.name}}
</option>
</select>
<input type="submit" value="Submit"/>
</form>
控制器
$scope.selectedDo;
$scope.selectedYear;
$scope.Display=function(){
$window.alert($scope.selectedDo+"..."+ $scope.selectedYear);
$http({
method:"post",
url:"/com.az.BusinessRatioAnalysis/SectionServlet",
data:{
year:$scope.selectedYear,
dosage:$scope.selectedDo,
}
}).then(function(result){
$window.alert("Ajex call failed" + result);
});
};
小服务程序
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String year=request.getParameter("year");
String dosage=request.getParameter("dosage");
System.out.println(year+".."+dosage);
}
小唯快跑啊
相关分类