I want to send data to controller action and I want to get value from action. But I cannot send value and I cannot convert value getting from controller to boolean, string etc..
contact =(List)response.sendRedirect("contact/login.action");
My contactController's login.action is below: (Also, I tried the boolean function)
@RequestMapping(value="/contact/login.action")
public @ResponseBody Map<String,? extends Object> login(@RequestParam Object data) throws Exception {
try{
List<Contact> contacts = contactService.login(data);
return getMap(contacts);
} catch (Exception e) {
}
return null;
}
My jsp codes are below:
<%@page import="com.loiane.web.ContactController"%>
<%@page import=" com.loiane.model.Contact"%>
<%@page import="java.util.List"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%
String result;
List<Contact> contact;
String loginUsername = request.getParameter("loginUsername");
String loginPassword = request.getParameter("loginPassword");
contact =(List)response.sendRedirect("contact/login.action");
out.println(request.getAttribute("message"));
if ((null != loginUsername && loginUsername.length() > 0) && (null != loginPassword && loginPassword.length() > 0)) {
if (contact.size()>0)
result = "{success:true}";
else
result = "{success:false,errors:{reason:'Login failed.Try again'}}";
} else {
result = "{success:false,errors:{reason:'Login failed.Try again'}}";
}
%>
<%=result %>