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