¹ØÓÚjavaÀ࣬ת·¢jspÒ³ÃæÎÊÌâ
package com;
import java.io.IOException;
import javax.servlet.jsp.PageContext;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class LoadClass extends ClassLoader {
private DocumentBuilderFactory dbf;
private DocumentBuilder bd;
private Document doc;
/**
* ¸ù¾Ý²ÎÊý,²éÕÒxml·µ»Ø½á¹û
*/
private String getStr(String str) {
try {
// ¼ÓÔØxml·½·¨
dbf = DocumentBuilderFactory.newInstance();
bd = dbf.newDocumentBuilder();
doc = bd.parse("struts-config.xml");
NodeList nl = doc.getElementsByTagName("action");
for (int i = 0; i < nl.getLength(); i++) {
Element ele = (Element) nl.item(i);
String tempname = ele.getAttribute("name");
if (str.equals(tempname)) {
return ele.getAttribute("class");
}
}
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Ïà¹ØÎÊ´ð£º
ÎҵĿª·¢µÄƽ̨ÊÇMyeclipes6.0 + tomcat5.x + mysql
ÎÒËùÓеıàÂ뷽ʽ¶¼ÊÇÓõÄUTF-8
ÎÒÖ»ÓÃÁËStrtus¿ò¼Ü
ÔÚÒ»¸öformÖÐÈçÏÂÓõÄÊÇpostµÄÌá½»·½Ê½£º
<form class="form" action=&quo ......
ÎÒµãºóÍËʱÊÇ¿Õ°×Ò³Ãæ
ÐèˢвÅÄÜÏÔʾ
Õâ¸öÔõô´¦Àí°¡
Çë´ó¼Ò°ï°ïæ
°ÑÎÊÌâ˵µÄÏêϸһЩ£¬ÕâÑùÓÐÖúÓÚÎÊÌâµÄ»Ø¸´£¬¼°´ð°¸µÄ׼ȷÐÔ£¡
ÎÒ¾õµÃÊÇÄãµÄä¯ÀÀÆ÷Æ÷µÄÎÊÌâ°É£¬ÎÒÒÔÇ°Óöµ½¹ýÕâÑùµÄÎÊÌ⣬°ÑIEµÄËùÓÐÊôÐÔÖ ......
ÎÒÏëµÇ¼ºó£¬Èç¹ûµÇ¼³É¹¦¾ÍÈ¥Ö´ÐÐij¸öÒ³Ãæ
ÎÒÏÖÔڵĴúÂëÊÇÕâÑùµÄ£º
if(rs.next()){
session.setAttribute( "username" , user);
<jsp:include page="login.jsp" />// ......
<%@page language="java" contentType="text/html;charset=gb2312" import="java.sql.*"%>
<jsp:useBean id="db" class="wang.connectDB"/>
< ......