日期:2014-05-20  浏览次数:20625 次

action接收URL参数问题
直接通过URL传值URL如:http://localhost:8080/jhxm/ltdx.action?sms.username=ltdx&sms.password=ltdx&sms.phone=1331094435&sms.SM_Content=fvgfb丰东¥%……&*()%20%20%20%20股份部分&sms.spNumber=&sms.motime=
我在Action中接收sms.SM_Content值时只能接受到“%”之前的值,之后的无法接受什么原因啊,如果用“&”也是同样效果只能接受&之前的不能后半部分被过滤掉饿了啊。怎么回事啊接收代码如下:
Java code

package com.qian.actions;

import java.util.Map;

import org.apache.taglibs.standard.tag.common.core.ParamSupport;
import org.omg.CORBA.Request;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.qian.biz.ReceiveBIZ;
import com.qian.vo.SMSendVO;

public class LtDxTSAction extends ActionSupport {
    // MainListener ml=new MainListener();
    SMSendVO sms = new SMSendVO();
    ReceiveBIZ biz = new ReceiveBIZ();

    public SMSendVO getSms() {
        return sms;
    }

    public void setSms(SMSendVO sms) {
        this.sms = sms;
    }
    public String execute() throws Exception {
        // ml.start();
        if (!sms.getUsername().trim().equals("")
                && !sms.getPassword().trim().equals("")) {
            if (sms.getUsername().equals("ltdx")
                    && sms.getPassword().equals("ltdx")) {
                if (sms.getPhone() != null || sms.getSpNumber() != null) {
                    String content=(String) parmas.get(sms.getSM_Content());

                    biz.receiveLTDX(sms.getPhone(), sms.getSpNumber(), sms
                            .getSM_Content(), sms.getMotime());
                    return "success";
                }
            } else {
                System.out.println("用户名密码错误");
                return "namepwderror";
            }
        } else {
            System.out.println("用户名密码不能为空");
            return "namepwdempty";
        }
        return "bzd";
    }
}



各位大哥大姐帮忙了啊


------解决方案--------------------
需要对这些参数用Base64编码吧
------解决方案--------------------
在url中这部分这样写&sms.SM_Content=encodeURIComponent(encodeURIComponent(fvgfb丰东¥%……&*()%20%20%20%20股份部分))//这里进行编码
在action中用urldecoder.decode(sms.getSM_Content(),"utf-8")//这里进行解码