日期:2014-05-17  浏览次数:20612 次

新手关于jsp表单乱码和页面数据更新需要刷新的问题(百度和谷歌了很久都没法解决故此求大神帮助)
小弟最近初学jsp,学习书籍是《JSP实用案例教程》 清华大学出版社,冯燕奎写的,在做一个投票系统的案例。我代码中所有的编码方式都是utf-8,包括文件编码也是utf-8。
tomcat 里的web.xml 设置的也是utf-8
Assembly code

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">
        <jsp-config>
    <jsp-property-group>  
        <description>     
            Special property group for JSP Configuration JSP example.  
        </description>  
        <display-name>JSPConfiguration</display-name>  
        <url-pattern>*.jsp</url-pattern>  
        <el-ignored>true</el-ignored>  
        <page-encoding>UTF-8</page-encoding>  
        <scripting-invalid>false</scripting-invalid>  
        <include-prelude></include-prelude>  
        <include-coda></include-coda>  
       
                  <description>     
            Special property group for JSP Configuration JSP example.  
        </description>  
        <display-name>JSPConfiguration</display-name>  
        <url-pattern>*.html</url-pattern>  
        <el-ignored>true</el-ignored>  
        <page-encoding>UTF-8</page-encoding>  
        <scripting-invalid>false</scripting-invalid>  
        <include-prelude></include-prelude>  
        <include-coda></include-coda>
            </jsp-property-group>
</jsp-config>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    

</web-app>




我又两个问题想请教大家。

第一个,增加项目提交form表单时中文乱码;
第二个,增加项目、删除项目之后details.jsp,admin.jsp页面需要刷新一次才能显示更改后的数据。

数据库是用书上的例子实用Access数据库,数据库连接正常,各种操作也正常。

下面是代码:
后台管理页面
admin.jsp
Assembly code

<%@page contentType="text/html;charset=UTF-8"%>
<%@page language="java" import="java.sql.*"%>
<jsp:useBean id="connDbBean" scope="page" class="vote.VoteConn"/>
<script language="JavaScript">
       window.location.reload();
</script>  
<html>
    <head>
        <title>后台</title>
        <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <body bgcolor="#ffffff">
        <div align="center">
            <p><font color="#990000" size="+2"><u>调查系统维护中心</u></font></p>
            <%
            ResultSet tempRs=connDbBean.executeQuery("select id,note from vote order by id");
            %>
            <table width="80%" border="0" cellspacing="1" cellpadding="2">
                <tr>
                    <td width="10%" class="text1" bgcolor="#99ccff">
                        <div align="center">序号<div>
                    </td>
                    <td width="80%" class="text1" bgcolor="#99ccff">
                        <div align="center">内容<div>
                    </td>