@Component("loginAction")
public class LoginAction extends CheCoreAction { private static final long serialVersionUID = 6787792267140504552L;
private LoginService loginService;
public LoginService getLoginService() {
return loginService;
} public void setLoginService(LoginService loginService) {
this.loginService = loginService;
} /**
* 登陆
*/
public String login(){
String backValue = "";
String username = "";
String password = "";
String sorce = "";
String phoneNum = "";
String result = "";
try {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/plain;charset=UTF-8");
JSONObject jsonParams = new JSONObject();
String str = request.getParameter("json");
if(!(str.equals("null") || null == str || str.length() == 0)){
jsonParams = JSONObject.fromObject(str);
sorce = (String) jsonParams.get("sorce");
username = (String) jsonParams.get("username");
password = (String) jsonParams.get("password");
backValue = loginService.login(username , password , sorce ,phoneNum);
if(sorce.equals("B")){
if(backValue.equals("0")){
result = "loginSuccess";
} else {
result = "loginError";
}
} else if(sorce.equals("M")){
phoneNum = (String) jsonParams.get("phoneNum");
JSONObject jsonResult = new JSONObject();
jsonResult.put("backValue", backValue);
response.getWriter().print(jsonResult.toString());
}
}
JSONObject jsonResult = new JSONObject();
jsonResult.put("backValue", backValue);
response.getWriter().print(jsonResult.toString());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
}
response.getWriter().print();
的意义在哪?
原因我找到了,问题出在jsp页面,原来师用的是submit,改成window.location就可以了,具体submit是因为啥不能跳转页面呢?
原因我找到了,问题出在jsp页面,原来师用的是submit,改成window.location就可以了,具体submit是因为啥不能跳转页面呢?
submit 是提交表单的,要配全<form action="">用的
这样写
<result>/pages/login/login.jsp</result>
没有找到转发
Action转发返回的是 这里的“名字”,你都没配置