我正在使用一个简单的 servlet 代码:
myCon = DriverManager.getConnection(url);
myStmt = myCon.createStatement();
ResultSet rs;
String course = req.getParameter("Course").trim();
out.println(course);///////HERE IS THE PROBLEM
String query="select * from TBSolvedbanks where COURSE_CODE='"+course+"' ;";
rs=myStmt.executeQuery(query);
out.println("<BANKS>");
while(rs.next())
{
out.println("<BANK>");
out.println("<NUMBER>"+rs.getString("NUMBER")+"</NUMBER>");
out.println("<NAME>"+rs.getString("NAME")+"</NAME>");
out.println("<TITLE>"+rs.getString("TITLE")+"</TITLE>");
out.println("<DESCRIPTION>"+rs.getString("DESCRIPTION")+"</DESCRIPTION>");
out.println("<MODULE_TAG>"+rs.getString("MODULE_TAG")+"</MODULE_TAG>");
out.println("<ADDITIONAL_TAGS>"+rs.getString("ADDITIONAL_TAGS")+"</ADDITIONAL_TAGS>");
out.println("</BANK>");
}
out.println("</BANKS>");
}
当我在 Jboss 服务器上运行此代码时,它工作正常并打印:
BEME1104
<BANKS>
<BANK>
<NUMBER>1</NUMBER>
<NAME>firstbank</NAME>
<TITLE>Question Bank 1</TITLE>
<DESCRIPTION>in this file,we discussed basic things including shortnotes of Properties of substances and aproaches</DESCRIPTION>
<MODULE_TAG>MODULE I</MODULE_TAG>
<ADDITIONAL_TAGS>Uses of point,path function,processes,equilibrium,curves</ADDITIONAL_TAGS>
</BANK>
但是当我评论这一行时
out.println(course);
它打印没有标签的值,如下所示:
"1 firstbank Question Bank 1 in this file,we discussed basic things including shortnotes of Properties of substances and aproaches MODULE I Uses of point,path function,processes,equilibrium,curves"
我不知道为什么我遇到这个问题,而相同的代码在另一个 servlet 中运行良好。请帮助我,我是 servlet 的新手?