0
獲得406不能接受的錯誤在我的web項目2種URL模式支持,當我在web.xml中指定兩個URL模式我想用Spring MVC的3 + jQuery的
<servlet-mapping>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<url-pattern>*.view</url-pattern>
</servlet-mapping>
下面
是我的服務器調用代碼
function showAll(){
console.log('inside all');
$.ajax({
url:'/SaveImages/ShowUser.view',
type: 'GET',
success: function (resp) {
},
error: function(e){
console.log('Error: '+e);
}
});
下面
是我的控制器代碼: -
@RequestMapping(value="/ShowUser.view", method=RequestMethod.GET)
public @ResponseBody User showUsers(ModelMap model) throws SQLException, IOException{
ResultSet rst=null;
User user=new User();
Connection conn=null;
PreparedStatement pst=null;
try{
conn=getConnection();
pst=conn.prepareStatement("select user_name,image_filename,image from save_image where pid=?");
pst.setInt(1, 2);
String name=null;
String fileName=null;
CommonsMultipartFile ip=null;
rst=pst.executeQuery();
BufferedInputStream input=null;
rst.next();
name = rst.getString(1);
fileName = rst.getString(2);
String filePath="xyz";
user.setName(name);
user.setEducation(ip);
user.setFilePath(filePath);
conn.close();
}
catch(Exception e){
e.printStackTrace();
}
finally{
rst.close();
pst.close();
conn.close();
//out.close();
}
return user;
}
我想通過在response.please幫助,我是一個模型對象努力爲此從過去3天。如果我使用.htm在Ajax網址我沒有得到任何響應對象。
thanx您的回覆....現在它的工作我指定dataType爲'json'並添加傑克遜jar – user2435082