📄 nativeaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package cn.hicc.sea.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import cn.hicc.sea.struts.form.NativeForm;
/**
* MyEclipse Struts
* Creation date: 11-28-2007
*
* XDoclet definition:
* @struts.action path="/native" name="nativeForm" input="/form/native.jsp" scope="request" validate="true"
*/
public class NativeAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
NativeForm nativeForm = (NativeForm) form;// TODO Auto-generated method stub
String sea = nativeForm.getSea() ;
char[]arChar=iso2gb(sea).toCharArray();
int iValue=0;
String uStr="";
for(int i=0;i<arChar.length;i++){
iValue=(int)iso2gb(sea).charAt(i);
if(iValue<=256){
// uStr+="�"+Integer.toHexString(iValue)+";";
uStr+="\\u00"+Integer.toHexString(iValue);
}else{
// uStr+="&#x"+Integer.toHexString(iValue)+";";
uStr+="\\u"+Integer.toHexString(iValue);
}
}
nativeForm.setSea(uStr);
request.setAttribute("native",nativeForm);
return mapping.findForward("succ");
}
// "gb2312"到"ISO-8859-1"的转码
public String iso2gb(String str) {
try {
str = new String(str.getBytes("ISO-8859-1"), "gb2312");
} catch (Exception e) {
System.out.println("Encoding Error!");
}
return str;
}
//"ISO-8859-1"到"gb2312"的转码
public String gb2iso(String str) {
try {
str = new String(str.getBytes("gb2312"), "ISO-8859-1");
} catch (Exception e) {
System.out.println("Encoding Error!");
}
return str;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -