Struts2+Spring2.5+ibatis+ExtJS3.1 基于注解框架搭建(3)
1、创建login.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="login" extends="struts-default">
<action name="initLogin">
<result name="success">/WEB-INF/portal/portal.jsp</result>
</action>
<!-- 转向添加页面 -->
<action name="loginAction" class="loginAction" method="login">
<result name="success">/WEB-INF/portal/portal.jsp</result>
</action>
</package>
</struts>
2、建立LoginAction.java
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
@Controller("loginAction")
@Scope("prototype")
public class LoginAction extends BaseAction
{
/**
* 注释内容
*/
private static final long serialVersionUID = 9146562136905868429L;
@Resource LoginService loginServiceImpl;
/**
* 登录验证
* <功能详细描述>
* @return
* @see [类、类#方法、类#成员]
*/
public String login()
{
HttpServletRequest request = getRequest();
String staffId = request.getParameter("staffId");
String staffPwd = request.getParameter("staffPwd");
boolean flag = loginServiceImpl.loginService(staffId, staffPwd);
String returnMsg = "{failure:false}";
if (flag)
{
// returnMsg = "{success:true}";
return SUCCESS;
}
else
{
returnMsg = "{failure:false}";
outJsonString(returnMsg);
return null;
}
}
}
3、创建Server接口和实现类
LoginService.java
public interface LoginService
{
public boolean loginService(String staffId, String password);
}
LoginServiceImpl.java
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
@Service("loginServiceImpl")
public class LoginServiceImpl extends BaseService implements LoginService
{
@Resource LoginDao loginDaoImpl;
public boolean