javaweb 网页

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>我的网页程序</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body  background="img.jpg">
    <center>
        <h2>
            <font color="blue">hello word</font>
        </h2>
        <h3>
            你是谁?
        </h3>
        <h1>嗨,欢迎来到网页编程学习世界!</h1>
        <table border="1" width="80%">
            <tr>
                <td colspan="6">
            <center> <font size="20">字体显示</font> </center>
                </td>
                <td rowspan="3">
                </td>
            </tr>
            <tr>
                <td><b>粗体</b>
                <td><b>粗<i>斜体</i>体</b>
                <td><u>下划线</u></td>
                <td><u>下<s>中划线</s>划线</u></td>
                <td>90<sup>o</sup></td>
                <td><font color="blue">H<sub>2</sub>O</font></td>
            </tr>
        </table>
        </center>
    <a href="http://localhost:8080/WebApplication3/index.html">转入用户登录界面</a>
    </body>
</html>
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>用户登录界面</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
    <form action="" method="post">
        编  号:<input type="text" name="userid" value="NO." size="2" maxlength="2"><br>
        密  码:<input type="password" name="userpass" value="请输入用户名"><br>
        性  别:<input type="radio" name="sex" value="boy" checked>男
                          <input type="radio" name="sex" value="girl">女<br>
        部  门:<select name="dept">
                              <option value="技术部">技术部</option>
                              <option value="财务部">财务部</option>
                              <option value="销售部" selected>销售部</option>
                          </select><br>
        兴  趣:<input type="checkbox" name="inst" value="唱歌">唱歌
                          <input type="checkbox" name="inst" value="唱歌">唱歌
                          <input type="checkbox" name="inst" value="游泳">游泳
                          <input type="checkbox" name="inst" value="编程" checked>编程<br>
        说  明:<textarea name="note"  cols="30" rows="6">
                                    请按照相关信息准确填写
                          </textarea><br>
        <input type="submit"  value="注册" ><input type="reset"  value="重置"> <br>              
    </form>
    <center> <font color="red" size="100">注意:请不要在公共网络上填写相关信息!</font></center>
    <a href="http://localhost:8080/WebApplication1/index.html">返回上一页</a>
    </body>
</html>


### JavaWeb 网页中文乱码解决方案 对于JavaWeb项目中的网页显示中文乱码问题,确保整个请求处理链路中字符编码的一致性至关重要。以下是几种有效的解决方案: #### 数据库连接字符串设置 数据库连接URL应指定`useUnicode=true`和`characterEncoding=UTF8`参数,以确保从数据库读取的数据使用UTF-8编码[^2]。 ```java String url = "jdbc:mysql://localhost:3306/dbname?useUnicode=true&characterEncoding=UTF8"; ``` #### Tomcat服务器配置调整 通过修改Tomcat的VM选项来设定默认文件编码为UTF-8可以有效防止控制台输出乱码。这可以通过编辑运行/调试配置实现,在`server->vm options`字段输入`-Dfile.encoding=UTF-8`并保存更改后重启服务[^3]。 #### IDE环境编码统一化 如果上述方法未能解决问题,则需进一步检查开发环境中各个层面的编码设置是否一致。建议进入IDE(如IntelliJ IDEA)的全局、项目及默认编码均设为UTF-8,并确认新建文件时不包含BOM标记。 #### Web应用程序内部过滤器 为了保证客户端提交给服务器端的数据能够被正确解析,可以在web.xml或者Spring框架下的配置类里定义一个CharacterEncodingFilter用于强制转换所有HTTP POST请求体内的字符集为UTF-8[^1]。 ```xml <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> ``` 以上措施综合运用可极大程度上减少甚至消除JavaWeb应用中存在的各种形式的中文乱码情况。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值