日期:2014-05-16  浏览次数:20558 次

spring mvc +ExtJs FromPanel提交以后怎样跳转
我想通过spring mvc的方式来控制页面的跳转前台用extjs.
我的后台代码:
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class TestController {

    @RequestMapping(value = "/test.htm", method = RequestMethod.POST)
    public String test(HttpSession sesstion, HttpServletRequest request,
            HttpServletResponse response, ModelMap map) {
        //System.out.println("success");
        try {
            String username = ServletRequestUtils.getStringParameter(request,
                    "username");
            //System.out.println(username);
            map.addAttribute("username", username);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return "portfolio/test";//这个是我要跳转的页面
    }

}

前台Extjs代码:
Ext.onReady(function() {
Ext.loginForm = Ext.extend(Ext.form.FormPanel, {
xtype : "form",
title : "登錄",
labelWidth : 100,
labelAlign : "center",
buttonAlign : 'right',
layout : "form",
width : 400,
padding : "10px",
initComponent : function() {
this.items = [{
xtype : "textfield",
fieldLabel : "使用者名稱",
name : "username",
anchor : "95%"
}, {
xtype : "textfield",
fieldLabel : "密碼",
name : "password",
anchor : "95%",
inputType : "password"
}, {
xtype : "checkbox",
boxLabel : "記住登錄狀態",
name : "spring_security_remember_me",
anchor : "100%"
}]
this.buttons = [{
xtype : "button",
text : "登入",
type : "submit",
scope : this,
handler : function() {
this.getForm().doAction("submit", {
url : "/test.htm",//我要提交的处理的页面
scope : this,
success : function(form, action) {
alert("success");
},
failure : function(form, action) {
Ext.Msg
.alert(
'Warning!',
'Authenti