-1
我想使用jstl throgh模型視圖做一個選擇框,我是一個純粹的noob,有人我已經通過這個,並創建此任何人都可以幫助我獲得monngodb值在選擇框中選擇框使用jstl彈簧4 MVC,mongodb
這裏是我的代碼
控制器
@RequestMapping(value = "getSpeciality", method = RequestMethod.GET)
public ModelAndView getSpeciality(HttpServletRequest request) {
Map<String, Object> myModel = new HashMap<String, Object>();
myModel.put("myVar", getSpeciality(UtilsManagementService.getSpeciality())); // here is showing error UtilsManagementService cannot be resolved
return new ModelAndView("view", myModel);
}
管理層
package com.geniedoc.management.service;
import java.util.List;
import com.geniedoc.exception.BussniessException;
import com.geniedoc.exception.UserNotFoundException;
import com.geniedoc.vo.CityVo;
import com.geniedoc.vo.SpecialityVO;
public interface UtilsManagementService {
public List<SpecialityVO> getSpeciality(String key) throws BussniessException; }
DB
@Override
public Speciality getSpeciality(String specialityName) {
Query findSpecialityQuery = new Query();
findSpecialityQuery.addCriteria(Criteria.where(SPECIALITY_NAME).regex(specialityName));
Speciality speciality = null;
try{
speciality = this.specialityRepository.getDocument(Speciality.class, findSpecialityQuery, SPECIALITY_TABLE);
}catch(MongoDBDocumentNotFoundException e){
e.printStackTrace();
}
return speciality;
}
和jsp
<select id="Speciality" name=""Speciality"">
<c:forEach var="item" items="${myModel}">
<option value="${item.key}">${item.value}</option>
</c:forEach>
</select>
專業VO
package com.geniedoc.vo;
public class SpecialityVO {
private int _id;
private String speciality_name;
private String speciality_description;
public String getSpeciality_name() {
return speciality_name;
}
public void setSpeciality_name(String speciality_name) {
this.speciality_name = speciality_name;
}
public String getSpeciality_description() {
return speciality_description;
}
public void setSpeciality_description(String speciality_description) {
this.speciality_description = speciality_description;
}
public int get_id() {
return _id;
}
public void set_id(int _id) {
this._id = _id;
}
}
你能告訴我們你面對的確切問題 –
@RamanaManoj在非常fisrt的代碼它顯示錯誤我已經給了那條線,它在哪裏給出錯誤//我想從mongodb獲取值並填充選擇標籤 – user6409738