0
我是Spring MVC框架的新手。我被卡住了一點。我想從當前的jsp頁面顯示另一個jsp頁面,爲此我在客戶端使用ajax。我在下面分享我的代碼。請幫我解決這個問題。 謝謝,從彈簧控制器重定向到jsp頁面
<li>
<a href="" onclick="displayEditProfile();" target="_blank">
<i class="glyphicon glyphicon-edit"></i>
Edit My Profile </a>
</li>
我的JavaScript函數:
function displayEditProfile(){
$.ajax({
url: '/HappyWorld/displayEditProfile.do',
data:{
//sharePost : $('#userPost').val(),
//"password":$('#passwordId').val(),
time : new Date(),
},
type: 'GET',
dataType: 'text',
success: function(data) {
},
error: function(xhr, textStatus, errorThrown) {
alert(xhr+" "+textStatus+" "+errorThrown);
}
});
}
我的控制器:
@RequestMapping(value="/displayEditProfile", method = RequestMethod.GET)
@ResponseBody
public ModelAndView displayEditProfile(HttpServletRequest request,HttpServletResponse response) {
System.out.println(" in call.");
return new ModelAndView("edit_user_profile");
}
和我的觀點xml配置是:
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/jsp/" p:suffix=".jsp" />
但爲什麼ajax要實現這個目標? – KDP
所以我該怎麼做? –
檢查我的以下答案 – KDP