wap页面,源码文件处理方案解析

来源:互联网 发布:弹幕点歌什么软件 编辑:程序博客网 时间:2024/06/04 17:49

现在wap越来越流行。

您肯定希望自己wap网页不被他们窃取文本内容。

这里提供一种简单方便的方法,实现这一功能。当然,只是让取用的人稍费先手脚。

下面贴出源码。

我在自己接的一个项目中使用了这样的方式实现源码不能查看功能,为大伙提供参考。

 

index.jsp

 

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@page import="com.bogao.wap.utilclass.mf"%>
<%String path = request.getContextPath();%>
<head>
<title><%=mf.s2u("登入界面") %></title>
<meta http-equiv="Cache-Control" content="max-age=0" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Cache-Control" content="must-revalidate" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" rev="stylesheet" href="http://localhost:8080/bg/typecss/wapbody.css" type="text/css"/>
</head>
<body>
<p class="pp"><%=mf.s2u("环境自动在线监测发布系统登入页面") %></p>
<form class="form_css" action="login.action" method="get">
<table cellpadding="0" cellspacing="0" style="padding: 0px; text-align: left">
    <tr>
        <td class="td_narrow"><%=mf.s2u("用户:") %></td>
        <td><input type="text" name="username" value="user" /></td>
    </tr>
    <tr>
        <td class="td_narrow"><%=mf.s2u("密码:") %></td>
        <td><input type="password" name="password" value="password" /></td>
    </tr>
    <tr>
        <td colspan="2" align="center">
   <input class="button" type="submit" name="submit" value="<%=mf.s2u("登入") %>"/>
            <input class="button" type="reset" name="" value="<%=mf.s2u("重置") %>"/>
        </td>
    </tr>
</table>
</form>
</body>
</html>

 

在页面显示内容的时候,看到了使用了mf.u2s()这个一个函数。

下面把mf源码贴出:

package com.bogao.wap.utilclass;
import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;

/*
 * 页面编码类
 */
public class mf {
 /*
  * 字符串转化函数,将字符串转化成16进制,进行显示。
  */
    public static String s2u(String text)
    {
        String result = "";
        int input;
        StringReader isr;
        try {
            isr = new StringReader(new String(text.getBytes("iso-8859-1"), "utf-8"));
        }
        catch (UnsupportedEncodingException e) {
            return text;
        }

        try {
            while ( (input = isr.read()) != -1) {
                result = result + "&#x" + Integer.toHexString(input) + ";";
            }
        }
        catch (IOException e) {
            return text;
        }
        isr.close();
        return result;
    }
}

 

处理的时候在每个16进制显示字符前加上了&#x。这个是浏览器识别显示内容必须的。

 

而出来的效果如下图:

 

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 被别人办了信用卡怎么办 考驾照体检忘带身份证怎么办 c证扣12分怎么办新规 c照12分不够扣怎么办 扣了18分怎么办一次性 c照累计扣12分怎么办 车辆超速扣12分怎么办 一次超速扣12分怎么办 分扣了罚款未交怎么办 c照一次扣12分怎么办 人在外地身份证到期了怎么办 手机进水了屏幕不亮怎么办 北京一证通过期怎么办 小米6音量键进水怎么办 考驾照怕过不了怎么办 学车对车没感觉怎么办 居住证到期2个月怎么办 生育险差一个月怎么办 驾照扣了38分怎么办 新疆转入山东上学怎么办手续 驾照过日期换证怎么办 机动车被扣24分怎么办 车辆被扣24分怎么办 现在深圳牌十年老车怎么办? 护士证过期4年了怎么办 护士资格证延续注册过期了怎么办 护士资格证过期没注册怎么办 护士资格证注册时间过期怎么办 辅警体检视力不行怎么办 护士延续注册体检怀孕怎么办 护士资格证没有延续注册怎么办 申请信用卡没有座机号码怎么办 网上申请信用卡没有座机号码怎么办 我叫上门服务被骗了怎么办 上门服务被骗了3000多怎么办 微信被骗9000元怎么办 奥迪a8气囊灯亮怎么办 驾考站岗迟到了怎么办 老板欠员工工资不给怎么办 如果有一天我没头发了怎么办 苏州公积金密码忘了怎么办