1.DbUnit (å®è£
| 使ç¨)
2.web项目中报错405-方法不允许的表p表解决方案
3.系统垃圾清理代码方法
DbUnit (å®è£ | 使ç¨)
è¿ç¨DBUnitè¿è¡é«æåå æµè¯
è¯è 注ï¼æè¿å¯¹DBUnitæ¯è¾æå ´è¶£ï¼çå°è¿ç¯æç« å°±ç¿»è¯åºæ¥åå¤§å®¶å ±äº«ï¼ä¸è¿æä¹æ¯New
Handï¼æ以翻è¯ä¸å¥½çå°æ¹è¯·å¤§å®¶ææ£ãæçMSN:zhlihui@hotmail.com,å¦æ大家æä»ä¹å¥½çèµæºåç»éªæ¬¢è¿åæ交æµ.
å¼å ¥DBUnit
ç°å®ç³»ç»ä¸é常ä¼æä¸äºå ·æå¤é¨ä¾èµæ§ç对象ï¼è¿äºå¯¹è±¡åæ°æ®åºæè å ¶ä»å¯¹è±¡åå¨è¯¸å¤å ³èãå¦ææ们对è¿æ ·ç对象ç¼ååå åç»ä»¶çº§æµè¯çè¯ï¼å¯ä»¥æ³è±¡å°æ¯é常麻ç¦çä¸ä»¶äº.å 为è¿ç§å¤é¨ä¾èµæ§çåå¨ï¼ä½¿çæ们å¾é¾å°å¯¹è±¡å¤ç«åºæ¥è¿è¡æµè¯ãç»å¸¸æåçç½çæµè¯æ³ï¼åºæ¬ä¸å°±æ¯éè¿æ§å¶å¯¹è±¡çå¤é¨ä¾èµæ§æ¥è¾¾å°é离对象çç®çï¼ä½¿çå¯ä»¥æä½è¿äºå¯¹è±¡çç¶æåç¸å ³è¡ä¸ºã
è¿ç¨ 模æ对象(mock objects)
æè stubsï¼å°±æ¯ä¸ä¸ªæ§å¶å¯¹è±¡å¤é¨ä¾èµæ§ç解å³æ¹æ¡ãéè¿é离é£äºå ³èçæ°æ®åºè®¿é®ç±»ï¼è±¡JDBCçç¸å ³æä½ç±»ï¼å¯¹äºæ§å¶å¯¹è±¡å¤é¨ä¾èµæ§å°æ¯å¾ææçãä½æ¨¡æ对象ç解å³æ¹æ¡å¯¹ä¸äºç¹æ®çåºç¨ç³»ç»æ¶æå°±æ¾å¾åä¸ä»å¿äºï¼è±¡é£äºè¿ç¨äºEJBçCMP(container-managed
persistence)æè JDO(java Data
Objects)çåºç¨ç³»ç»æ¶æï¼å¨è¿äºæ¶æéï¼æ°æ®åºç访é®å¯¹è±¡æ¯å¨æåºå±çèä¸å¾éè½ã
ç±Manuel Laflamme
ç¼åçå¼æ¾æºä»£ç çDBUnitæ¶æä½ç³»ï¼å¯¹äºæ§å¶ç³»ç»å é¨çæ°æ®åºä¾èµæ§æä¾äºä¸ä¸ªé常ä¸éç解å³æ¹æ¡ãä»å 许ç¨åºåå¨æ´ä¸ªçæµè¯è¿ç¨ä¸èªç±ç管çæ§å¶æ°æ®åºçç¶æï¼è¿å¾éè¦ãå©ç¨DBUnitï¼å¨æµè¯ä¹åï¼æ们å¯ä»¥ç»ç®æ æ°æ®åºæ¤å ¥æ们éè¦çæ°æ®éï¼èä¸ï¼å¨æµè¯å®æ¯åï¼æ°æ®åºå®å ¨è½å¤å溯å°æµè¯åçç¶æã
å¨å¾å¤æåç软件项ç®ä¸ï¼æµè¯èªå¨åå¾å¾æ¯å ³é®çå±é¢ãDBUnitå 许å¼å人åå建æµè¯ç¨ä¾ä»£ç ï¼å¨è¿äºæµè¯ç¨ä¾ççå½å¨æå æ们å¯ä»¥å¾å¥½çæ§å¶æ°æ®åºçç¶æãèä¸,è¿äºæµè¯ç¨ä¾æ¯å¾å®¹æå®ç°èªå¨åçãè¿æ ·å¨æµè¯è¿ç¨ä¸æ们æ 须对å®è¿è¡äººå·¥çå¹²é¢ï¼ä¸ºäººå·¥å¹²é¢é æçåæèæ å¿å°±æ´æ²¡å¿ è¦äºã
ç®åä»ç»
é 置使ç¨DBUnitç第ä¸æ¥æ们é¦å éè¦ç¥éå¦ä½çææ°æ®åºschemaï¼è¿ä¸ªæ件æ¯XMLæ ¼å¼çï¼å ¶ä¸å æ¬äºæ°æ®åºç表åç¸å ³æ°æ®ä¿¡æ¯ã
ä¾å¦ï¼è¿éæä¸ä¸ªæ°æ®åºè¡¨employee
ï¼æ们å¯ä»¥ç¨SQLçå½¢å¼è¿æ ·å°ä»è¡¨ç¤ºåºæ¥ã
èä¸ï¼æ们å¯ä»¥çå°ï¼ä¸ä¸ªç®åçæ°æ®éå¯ä»¥è¿æ ·è¡¨ç¤º
å¨DBUnitä¸ï¼ä¸é¢è¿ä¸ªè¡¨åæ½æ ·æ°æ®ä¿¡æ¯å¯ä»¥ç¨XMLæ件çå½¢å¼è¿æ ·è¡¨ç¤ºï¼
<EMPLOYEE employee_uid='1'
start_date='--'
first_name='Andrew'
ssn='xxx-xx-xxxx'
last_name='Glover' />
è¿ä¸ªçæçXMLæ ¼å¼çæ件å¯ä»¥ä½ä¸ºç³»ç»æéçææç§åæ件(seed
files)çæ ·æ¬æ¨¡ç.
为ç¸äºå ³èçæµè¯åºæ¯å建å¤ä¸ªç§åæ件æ¯ä¸ä¸ªå¾ææççç¥ï¼å°±è±¡éè¿ä¸åçæ°æ®åºæ件æ¥åºåé离æ°æ®åºç¶ææ¯ä¸ä¸ªéçãå¤ç§åæ件çç¥å¯ä»¥å°æ们çæµè¯ç®æ éå®å°è¾å°çèå´ï¼ç®æ æ°æ®å¯ä»¥åªé对æ°æ®åºç表ï¼èä¸æ¯æ´ä¸ªæ°æ®åºã
为äºç»ç®æ æ°æ®åºæ¤å ¥ä¸åçèåè®°å½ï¼æ们éè¦çXMLæ°æ®æ件å¦ä¸æ示ï¼
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<EMPLOYEE employee_uid='1'
start_date='--'
first_name='Drew' ssn='--'
last_name='Smith' />
<EMPLOYEE employee_uid='2'
start_date='--'
first_name='Nick' ssn='--'
last_name='Marquiss' />
<EMPLOYEE employee_uid='3'
start_date='--'
first_name='Jose' ssn='--'
last_name='Whitson' />
</dataset>
ç°å¨ï¼è¦è®©DBUnitåæ们æéçæ°æ®åºschemaä¸èµ·å·¥ä½äºï¼å¯¹äºç¨åºåæ¥è¯´ï¼æ们使ç¨DBUnitè¿è¡æµè¯å¯ä»¥æ两ç§éæ©ï¼éè¿ç´æ¥ç¼ç æ¹å¼è¿è¡æµè¯æè ä¸Antç»å.
ç¼ç æ¹å¼
DBUnitæ¡æ¶æä¾äºä¸ä¸ªåºæ¬çæ½è±¡æµè¯ç¨ä¾ç±»ï¼å«åDatabaseTestCaseï¼å®æ¯JUnitæ¡æ¶ä¸çåºç¡ç±»TestCaseçåç±»ãå¦ææ们使ç¨è¿ä¸ªç±»å¿ é¡»é¦å å®ç°ä¸¤ä¸ªé©åæ¹æ³(hook
methods)ï¼getConnection()ågetDataSet().
æ¹æ³getConnection()éè¦è¿åä¸ä¸ªIDatabaseConnectionç±»åç对象ï¼è¿ä¸ªå¯¹è±¡æ¯ä¸ä¸ªåºäºæ®éJDBCè¿æ¥çå è£ ç±»ãä¾å¦ï¼ä¸é¢ç代ç 段æ¼ç¤ºäºå¨MySQLæ°æ®åºç¯å¢ä¸ï¼IDatabaseConnectionç±»åè¿æ¥å¯¹è±¡çå建æ¹æ³ã
protected IDatabaseConnection getConnection()
throws Exception {
Class driverClass = Class.forName("org.gjt.mm.mysql.Driver");
Connection jdbcConnection = DriverManager.getConnection(
"jdbc:mysql://.0.0.1/hr", "hr", "hr");
return new DatabaseConnection(jdbcConnection);
}
æ¹æ³getDataSet()è¿åä¸ä¸ªIDataSetç±»å对象ï¼å ¶å®ï¼è¯´ç½äºï¼ä»å°±æ¯æ们å åæå°çXMLæ°æ®çç§åæ件çå¦ä¸ç§è¡¨ç°å½¢å¼ã
protected IDataSet getDataSet() throws Exception {
return new FlatXmlDataSet(
new
FileInputStream("hr-seed.xml"));
}
æäºè¿ä¸¤ä¸ªåºæ¬çæ¹æ³ä»¥åï¼DBUnitå°±å¯ä»¥æç §å®é¢å 缺ççè¡ä¸ºå·¥ä½äºãDatabaseTestCaseç±»æä¾äºä¸¤ä¸ªfixtureï¼æå«å®åºä»¶ï¼ä¸ç¥ä»å åæå¦ï¼ï¼æ¹æ³æ¥æ§å¶æµè¯ååæµè¯åçæ°æ®åºç¶æãè¿ä¸¤ä¸ªæ¹æ³å°±æ¯ï¼
getSetUpOperation() å getTearDownOperation().
ä¸ç§é«æçå®æ½æ¹æ¡å°±æ¯è®©getSetUpOperation()æ¹æ³æ§è¡REFRESHæä½ï¼éè¿è¿ä¸ªæä½,æ们å¯ä»¥ç¨ç§åæ件ä¸çæ°æ®å»æ´æ°ç®æ æ°æ®åºéçæ°æ®ãæ¥ä¸æ¥ï¼å°±æ¯getTearDownOperation()ï¼è®©ä»å»æ§è¡ä¸ä¸ªNONEæä½ï¼ä¹å°±æ¯ä»ä¹ä¹ä¸æ§è¡ã
protected DatabaseOperation getSetUpOperation()
throws
Exception {
return DatabaseOperation.REFRESH;
}
protected DatabaseOperation getTearDownOperation()
throws
Exception {
return DatabaseOperation.NONE;
}
è¿æä¸ç§ææçæ¹æ³å°±æ¯å¨getSetUpOperation()æ¹æ³ä¸æ§è¡CLEAN_INSERTæä½ï¼è¿æ ·é¦å ä¼å°ç®æ æ°æ®åºä¸ä¸æ们æä¾çç§åæ件ä¸è´çæ°æ®å é¤ï¼ç¶åå°æ们æä¾çæ°æ®æå ¥å°æ°æ®åºä¸ãè¿ä¸ªå®æ½é¡ºåºä¿è¯äºæ们对æ°æ®åºç精确æ§å¶ã
代ç æ ·ä¾
å¨ä¸ä¸ªåºäºJ2EEç人åèµæºç³»ç»ä¸ï¼æ们å¾å¸æ对æ个æ°æ®æä½å¨æå®ç°æµè¯èªå¨å,è¿ä¸ªæä½å¨æå æ¬èåçæ°å¢ï¼æ£ç´¢ï¼æ´æ°åå é¤ãè¿ç¨æ¥å£å®ä¹äºä¸åçä¸å¡æ¹æ³ï¼ä¸ºäºç®æ´æ¸ æ¥ï¼çç¥äºæ¹æ³ä¸çthrowsåå¥ï¼.
//è¯è 注ï¼è¿éçEmployeeValueObjectç±»å对象ï¼è¯è 认为æ¯ä»£è¡¨èåå®ä½ä¿¡æ¯ç对象ã
public void createEmployee( EmployeeValueObject emplVo )
public EmployeeValueObject getEmployeeBySocialSecNum( String ssn )
public void updateEmployee( EmployeeValueObject emplVo )
public void deleteEmployee( EmployeeValueObject emplVo )
æµè¯getEmployeeBySocialSecNum()æ¹æ³
éè¦æ¤å ¥ä¸æ¡æ°æ®å°ç®æ æ°æ®åºä¸ï¼å¦å¤ï¼æµè¯deleteEmployee()æ¹æ³åupdateEmployee()æ¹æ³æ¶ï¼åæ ·ä¹æ¯å¨å åæ¤å ¥çè¿æ¡è®°å½çåºç¡ä¸è¿è¡ãæåï¼æµè¯ç±»ä¼é¦å å©ç¨createEmployee()æ¹æ³å建ä¸æ¡è®°å½ï¼åæ¶æ们éè¦æ ¡éªæ§è¡è¿ä¸ªæ¹æ³æ¶ï¼æ¯å¦ä¼æå¼å¸¸åçã
ä¸é¢è¿ä¸ªDBUnitç§åæ件ï¼å«å"employee_hr_seed.xml",ä¸é¢å°ç¨å°è¿ä¸ªæ件ã
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<EMPLOYEE employee_uid='1'
start_date='--'
first_name='Drew' ssn='--'
last_name='Smith' />
<EMPLOYEE employee_uid='2'
start_date='--'
first_name='Nick' ssn='--'
last_name='Marquiss' />
<EMPLOYEE employee_uid='3'
start_date='--'
first_name='Jose' ssn='--'
last_name='Whitson' />
</dataset>
æµè¯ç±» EmployeeSessionFacadeTest
,éè¦æ©å±DBUnitçåºç¡ç±»DatabaseTestCase并ä¸å¿ é¡»æä¾å¯¹getConnection()ågetDataSet()æ¹æ³çå®ç°ï¼å¨getConnection()æ¹æ³ä¸å°è·å¾ä¸EJB容å¨åå§åæ¶ä¸æ ·çæ°æ®åºå®ä¾ï¼getDataSet()æ¹æ³è´è´£è¯»åä¸é¢æåçemployee_hr_seed.xmlæ件çæ°æ®ã
æµè¯æ¹æ³ç¸å½ç®åï¼å 为DBUnitå·²ç»ä¸ºæ们å¤çäºå¤æçæ°æ®åºçå½å¨æä»»å¡ã为äºæµè¯getEmployeeBySocialSecNum()æ¹æ³ï¼åªéè¦ç®åçä¼ éä¸ä¸ªåå¨äºç§åæ件ä¸ç社ä¿ä»£ç å·å³å¯,æ¯å¦
"--".
//è¯è 注ï¼EmployeeFacade ç±»å对象ï¼è¯è 认为æ¯ä»£è¡¨åºå±æ°æ®åºæ°æ®çæ å°ä½
public void testFindBySSN() throws Exception{
EmployeeFacade facade = //obtain somehow
EmployeeValueObject vo =
facade.getEmployeeBySocialSecNum("--");
TestCase.assertNotNull("vo shouldn't be null", vo);
TestCase.assertEquals("should be Drew",
"Drew", vo.getFirstName());
TestCase.assertEquals("should be Smith",
"Smith", vo.getLastName());
}
为äºç¡®ä¿æä½å¨æä¸çå建èåæ¹æ³createEmployee()没æé®é¢ï¼æ们åªéç®åçæ§è¡ä¸ä¸è¿ä¸ªæ¹æ³ï¼ç¶åæ ¡éªä¸ä¸çæ没æå¼å¸¸æåºï¼å¦å¤ï¼ä¸ä¸æ¥æ们è¦åçå°±æ¯å¨è¿æ¡æ°å¢çè®°å½ä¸è¿è¡æ¥æ¾æä½ï¼çæ¯å¦å¯ä»¥æ¾å°åå建çè®°å½ã
public void testEmployeeCreate() throws Exception{
EmployeeValueObject empVo = new EmployeeValueObject();
empVo.setFirstName("Noah");
empVo.setLastName("Awan");
empVo.setSSN("--");
EmployeeFacade empFacade = //obtain from somewhere
empFacade.createEmployee(empVo);
//perform a find by ssn to ensure existence
}
æµè¯updateEmployee()æ¹æ³å æ¬åæ¥ï¼é¦å æ¥æ¾æ们éè¦è¢«æ´æ°çé£æ¡è®°å½ï¼ç¶åæ´æ°å®ï¼ç´§æ¥çï¼éæ°æ¥æ¾è¿æ¡è®°å½ï¼ç¡®è®¤æ´æ°æä½æ¯å¦ææã
public void testUpdateEmployee() throws Exception{
EmployeeFacade facade =//obtain facade
EmployeeValueObject vo =
facade.getEmployeeBySocialSecNum("--");
TestCase.assertNotNull("vo was null", vo);
TestCase.assertEquals("first name should be Jose", "Jose",
vo.getFirstName());
vo.setFirstName("Ramon");
facade.updateEmployee(vo);
EmployeeValueObject newVo =
facade.getEmployeeBySocialSecNum("--");
TestCase.assertNotNull("vo was null", newVo);
TestCase.assertEquals("name should be Ramon", "Ramon",
newVo.getFirstName());
}
ç¡®ä¿æ°æ®æä½å¨æä¸çå é¤æä½deleteEmployee()çæ¹æ³åtestUpdateEmployee()æ¹æ³åºæ¬ç±»ä¼¼ã
å®å为ä¸æ¥ï¼é¦å æ¥æ¾ä¸ä¸ªå·²åå¨çè®°å½å®ä½ï¼ç¶å移é¤ï¼æåå对ç¸åçè®°å½è¿è¡æ¥æ¾ï¼ç¡®è®¤è¿æ¡è®°å½æ²¡æ被æ¥å°ã
public void testDeleteEmployee() throws Exception{
EmployeeFacade facade = //obtain facade
EmployeeValueObject vo = facade.getEmployeeBySocialSecNum("--");
TestCase.assertNotNull("vo was null", vo);
facade.deleteEmployee(vo);
try{
EmployeeValueObject newVo =
facade.getEmployeeBySocialSecNum("--");
TestCase.fail("returned removed employee");
}catch(Exception e){
//ignore
}
}
ä¸è¿°è¿äºæµè¯ä»£ç å¾ç®åä¹å¾å®¹æç解.å 为è¿äºä»£ç å¯ä¸çè责就æ¯æµè¯ï¼å·²ç»å®å ¨ä»ç³»ç»ç¨åºä»£ç ä¸ç¬ç«åºæ¥ï¼è¿ä½¿æµè¯åçç®åã并ä¸ï¼è¿äºæµè¯ç¨ä¾çèªå¨åä¹å¾å®¹æå®ç°ã
ä¸Antçç»å
ç¸å¯¹äºæ©å±DBUnitä¸çåºç¡ç±»DatabaseTestCase,DBUnitæ¡æ¶ä¸èªå¸¦Antåè½,å 许æ们å¯ä»¥å¨Antçbuild.xmlæ件ä¸æ§å¶æ°æ®åºçç¶æ.è¿ä¸ªåè½æ¯ç¸å½å¼ºå¤§çï¼å 为对äºä½æç诸å¤æµè¯ç¨ä¾ï¼å®æä¾äºä¸ä¸ªç¸å½ç®æ´ç解å³æ¹æ¡ãæ¯å¦ãå¨Antä¸è¿è¡JUnitæµè¯,就象ä¸é¢å®ä¹ä¸ä¸ªä»»å¡ä¸æ ·ç®åæäºã
<junit printsummary="yes" haltonfailure="yes">
<formatter type="xml"/>
<batchtest fork="yes"
todir="${ reports.tests}">
<fileset dir="${ src.tests}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
DBUnitä»»å¡è¿ç¨ä¸ï¼ä¸ºäºå¨Junitä»»å¡ååæ§å¶æ°æ®åºçç¶æï¼æ们éè¦å建ä¸ä¸ª"setup"æä½ï¼å¨è¿ä¸ªæä½ä¸ç§åæ件ä¸çæ°æ®å 容ä¼è¢«æå ¥çæ°æ®åºä¸ã
<taskdef name="dbunit"
classname="org.dbunit.ant.DbUnitTask"/>
<dbunit driver=" org.gjt.mm.mysql.Driver "
url=" jdbc:mysql://.0.0.1/hr "
userid="hr"
password="hr">
<operation type="INSERT"
src="seedFile.xml"/>
</dbunit>
ç¶åï¼è¿éè¦ä¸ä¸ª"tear
down"æä½,å¨è¿ä¸ªæä½ä¸ï¼"setup"æä½æå ¥çè®°å½è¢«ä»ç®æ æ°æ®åºä¸å é¤äºã
<dbunit driver=" org.gjt.mm.mysql.Driver "
url=" jdbc:mysql://.0.0.1/hr "
userid="hr"
password="hr">
<operation type="DELETE"
src="seedFile.xml"/>
</dbunit>
ç¨ä¸é¢ç代ç æ¥å è£ JUnitä»»å¡ï¼è½å¤å¨æ¹éæµè¯åææçè£ è½½æ°æ®å°ç®æ æ°æ®åºä¸ï¼å¹¶ä¸å¨æµè¯ç»æåï¼å°å·²è£ è½½çå ¨é¨æ°æ®å é¤ã
<taskdef name="dbunit"
classname="org.dbunit.ant.DbUnitTask"/>
<!-- set up operation -->
<dbunit driver=" org.gjt.mm.mysql.Driver "
url=" jdbc:mysql://.0.0.1/hr "
userid="hr"
password="hr">
<operation type="INSERT"
src="seedFile.xml"/>
</dbunit>
<!-- run all tests in the source tree -->
<junit printsummary="yes" haltonfailure="yes">
<formatter type="xml"/>
<batchtest fork="yes" todir="${ reports.tests}">
<fileset dir="${ src.tests}">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
</junit>
<!-- tear down operation -->
<dbunit driver=" org.gjt.mm.mysql.Driver "
url=" jdbc:mysql://.0.0.1/hr "
userid="hr"
password="hr">
<operation type="DELETE"
src="seedFile.xml"/>
</dbunit>
ç»è®º
è½å¤å¨æµè¯å¨æå 管çæ°æ®åºçç¶æï¼DBUnitæ¡æ¶çè¿ä¸ªåè½ç¹æ§ä½¿å¾æµè¯ç¨ä¾ä»£ç çå建ååºç¨çå¨æ大大缩çãèä¸ï¼éè¿æ§å¶æ°æ®åºè¿ä¸ªä¸»è¦çä¾èµå¯¹è±¡ï¼ä½¿çå©ç¨DBUnitæ¡æ¶ççæµè¯æ´å®¹æèªå¨åã
DBUnitç²¾å¦ç设计ï¼ä½¿çå¦ä¹ 使ç¨å®åå¾å¾ç®åãå¨ä½ çæµè¯æ¹æ¡ä¸ï¼å¦æä½ è½å¤æ£ç¡®ç使ç¨å®ï¼é£ä¹å¸¦æ¥çå°æ¯ä»£ç 稳å®æ§æ¹é¢çå¤§å¹ åº¦å¢å¼ºï¼å½ç¶è¿ä¼ä½¿ä½ çå¼åå¢éä¿¡å¿åå¢ã
web项目中报错-方法不允许的解决方案
在进行jsp+servlet开发时,可能会遇到报错的源码情况,特别是结构当尝试删除用户时,点击删除按钮后出现此错误。表p表问题主要在于代码逻辑中,源码Servlet方法调用的结构wvdial 源码不当。具体场景下,表p表用户列表的源码删除操作在doGet方法中执行,然后调用doPost方法进行处理。结构在处理完毕后,表p表应跳转至查询所有数据的源码Servlet并展示数据。
但现实情况是结构,数据并未展示出来。表p表同花顺昨日换手源码检查数据库发现,源码用户已被删除,结构但页面并未跳转至home.jsp页面。深入查看错误,得知是URL不支持POST,虽然发送的显示锁源码解析是GET请求,却收到POST不被支持的错误。经过跟踪,发现并没有进入EmpListServlet类的doPost方法。仔细观察后发现,问题出在EmpListServlet类的doGet方法中,调用了doPost方法中的c怎么修改源码super.doPost。
查看super.doPost源码后发现,这是一个HttpServlet类中的方法。在这个方法中,根据HTTP协议版本,发送特定错误代码至前端,即显示错误。怎么编辑游戏源码问题的关键在于,这个方法并未实现任何功能,只是根据协议版本返回错误信息。
在传统Servlet处理过程中,经常在doGet方法中调用doPost方法,但需要注意的是,调用的应该是自己实现的方法,而非父类中未实现的方法。因此,将super.doPost改为doPost即可解决问题。
系统垃圾清理代码方法
1、win7系统下点击电脑屏幕左下角开始所有程序附件记事本,然后把下面的蓝色代码复制进去:
@echo off
echo 正在进行系统垃圾清除,请耐心等待......
del /f /s /q %systemdrive%*.tmp
del /f /s /q %systemdrive%*._mp
del /f /s /q %systemdrive%*.log
del /f /s /q %systemdrive%*.gid
del /f /s /q %systemdrive%*.chk
del /f /s /q %systemdrive%*.old
del /f /s /q %systemdrive% ecycled*.
*del /f /s /q %windir%*.bak
del /f /s /q %windir%prefetch*.
*rd /s /q %windir% emp md %windir% emp
del /f /q %userprofile%cookies*.
*del /f /q %userprofile% ecent*.
*del /f /s /q %userprofile%Local SettingsTemporary Internet Files*.
*del /f /s /q %userprofile%Local SettingsTemp*.
*del /f /s /q %userprofile% ecent*.
*echo 清除系统垃圾完成!
echo. pause
2、将上面的代码完成复制后,点击文件,另存为
3、在弹出的另存为窗口中,先单击桌面,在保存类型下拉菜单中选择所有类型(*.*),并在文件名处输入源代码一键系统垃圾清理.bat,然后点击保存。
4、此时在电脑桌面上就能够看到源代码一键系统垃圾清理.bat文件然后双击它。
5、耐心等待程序清除系统垃圾清理完成。