@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;
}

}

解决方案 »

  1.   

    有return啊,而且log中已经打了
      

  2.   

    楼主是异步提交的吗?如果是的话,那页面肯定是不会变的如果不是异步提交的话,那楼主使用
    response.getWriter().print();
    的意义在哪?
      

  3.   

    不是异步提交,response.getWriter().print();是另一种登陆的返回值啊
      

  4.   

    代码有完整吗,我怎么没看到request在哪里定义的。也许你可以单步调试一下,你的代码到底怎么进行的。贴的太乱了,看着好不舒服
      

  5.   

    谢谢你们的帮助
    原因我找到了,问题出在jsp页面,原来师用的是submit,改成window.location就可以了,具体submit是因为啥不能跳转页面呢?
      

  6.   

    谢谢你们的帮助
    原因我找到了,问题出在jsp页面,原来师用的是submit,改成window.location就可以了,具体submit是因为啥不能跳转页面呢?
    submit 是提交表单的,要配全<form action="">用的
      

  7.   

    <result>pages/login/login.jsp</result>
    这样写
    <result>/pages/login/login.jsp</result>
    没有找到转发
      

  8.   

    <result name="名字">/pages/login/login.jsp</result>
    Action转发返回的是 这里的“名字”,你都没配置