我正在使用jsp和servlet构建Web应用程序,我从jsp发送ajax请求,我想从servlet返回两个json对象.我试着做以下但是代码不起作用.
//在jquery中我写了这段代码
var id = $(this).attr('id');
var paramenters = {"param":id};
$.getJSON("MyServlet", paramenters, function (data1,data2){
$("h3#name").text(data1["name"]);
$("span#level").text(data1["level"]);
$("span#college").text(data2["college"]);
$("span#department").text(data2["department"]);
});
Run Code Online (Sandbox Code Playgroud)
//在servlet中我编写了这段代码
String json1 = new Gson().toJson(object1);
String json2 = new Gson().toJson(object2);
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
response.getWriter().write(json1);
response.getWriter().write(json2);
Run Code Online (Sandbox Code Playgroud)
有人能帮我吗???
如何在不使用id或类的情况下使用jquery按名称获取html元素?有没有办法做到这一点?
我使用此代码使用php发送带附件的电子邮件,但由于我收到电子邮件并且附件出现在内容中,因此附件中存在错误.在我使用相同的代码并且它成功运行之前.为什么???
<?php
// sending email with attachments
function sendEmail($to,$from,$file,$ext){
$to = "admin@fuwant.com";
$from = "noor@fuwant.com";
$subject = "Translation Request";
$random_hash = md5(date('r', time()));
$headers = "From: sahar@fuwant.com\r\nReply-To: admin@fuwant.com";
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
$attachment = chunk_split(base64_encode(file_get_contents("Test.doc")));
$output = "
--PHP-mixed-$random_hash;
Content-Type: multipart/alternative; boundary='PHP-alt-$random_hash'
--PHP-alt-$random_hash
Content-Type: text/plain; charset='iso-8859-1'
Content-Transfer-Encoding: 7bit
Hello World!
This is the simple text version of the email message.
--PHP-alt-$random_hash
Content-Type: text/html; charset='iso-8859-1'
Content-Transfer-Encoding: 7bit
<h2>Hello World!</h2>
<p>This is the <b>HTML</b> version of the email message.</p>
--PHP-alt-$random_hash--
--PHP-mixed-$random_hash …Run Code Online (Sandbox Code Playgroud) 有谁能告诉我为什么我会收到这个错误,以及如何解决这个问题?
org.codehaus.staxmate.dom.DOMConverter中org.codehaus.staxmate.dom.DOMConverter._build(DOMConverter.java:188)中的线程"main"java.lang.NoClassDefFoundError:org/codehaus/stax2/ri/Stax2ReaderAdapter中的异常.buildDocument(DOMConverter.java:171)位于org.codehaus.staxmate.dom.DOMConverter.buildDocument(DOMConverter.java:152)的org.codehaus.staxmate.dom.DOMConverter.buildDocument(DOMConverter.java:131)xmlprocessing. api.STAXModifyCV.main(STAXModifyCV.java:68)由java.security上的java.net.URLClassLoader $ 1.run(URLClassLoader.java:202)中的java.lang.ClassNotFoundException:org.codehaus.stax2.ri.Stax2ReaderAdapter引起的java.lang上的java.net.URLClassLoader.findClass(URLClassLoader.java:190)中的.AccessController.doPrivileged(Native Method).class.Loader.loadClass(ClassLoader.java:307)at sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:301)at java.lang.ClassLoader.loadClass(ClassLoader.java:248)... 5更多Java结果: 1
我写了下面的代码:
//-*-*-
FileInputStream input = new FileInputStream("cv.xml");
XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(input);
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//-*-*- get new entries from input stream
System.out.println("<< Sahar CV >>\n -> Modify the first reference\n ** Modify The Name **");
System.out.print(" Enter degree : ");
String degree = in.readLine();
System.out.print(" Enter first name : ");
String fName = in.readLine();
System.out.print(" Enter last name : ");
String lName = in.readLine();
System.out.println(" …Run Code Online (Sandbox Code Playgroud) 我开发了一个客户端 - 服务器java应用程序,我使用ObjectOutputStream和ObjectInputStream在客户端和服务器进程之间发送和接收数据.我需要发送数组或对象或原始数据,但当我使用ObjectOutputStream和ObjectInputStream发送和接收原始值(writeDouble(),readDouble(),writeUTF(),readUTF())时出现问题.该计划暂停并停止工作.为什么,问题是什么?
这些是我程序的一部分
// client program
ObjectOutputStream toServer;
ObjectInputStream fromServer;
// Establish connection with the server
Socket socket = new Socket(host, 7000);
// Create an output stream to the server
toServer = new ObjectOutputStream(socket.getOutputStream());
fromServer = new ObjectInputStream(socket.getInputStream());
double num1 = Double.parseDouble(jtf1.getText().trim());
double num2 = Double.parseDouble(jtf2.getText().trim());
try {
toServer.writeUTF("multiply");
toServer.writeDouble(num1);
toServer.writeDouble(num2);
double result = fromServer.readDouble();
res.setText(String.valueOf(result));
} catch (IOException ex) {
System.err.println(ex);
}
// server program
private ObjectOutputStream outputToClient;
private ObjectInputStream inputFromClient;
// Create a server socket
ServerSocket serverSocket …Run Code Online (Sandbox Code Playgroud) 我创建了一个plsql函数,我想创建一个游标并从函数返回此光标.然后我想在Java类中调用此函数并从游标中检索数据.注意:光标返回一行.我写了这样的东西,
CREATE OR REPLACE
FUNCTION FUNCTION1 ( emp_id IN NUMBER)RETURN cursor AS
cursor newCursor(e_id number) is
select * from table1 where employee_id = e_id;
type refCursor is ref cursor;
BEGIN
open newCursor(emp_id);
loop
exit when newCursor%notfound;
fetch newCursor into refCursor;
end loop;
RETURN refCursor;
END FUNCTION1;
Run Code Online (Sandbox Code Playgroud)
如果我想返回游标,我应该使用什么返回类型?
我想使用id获取特定兄弟元素的值,我在运行时构建表单,并且有许多元素具有相同的id但在不同的部分.我试图使用$(this).siblings("#BillNo").val(); $(本).prev( "#BillNo")VAL().但两者都返回未定义的值
这个代码在运行时:佣金
<div id="bill1" class="bill hide withPadding">
<h3>Bill 1</h3>
<span>
<label>Bill no</label>
<input type="text" name="billNo" class="textField" id="BillNo"/>
</span>
<span>
<label>Bill total</label>
<input type="text" name="billTotal" class="textField" id="BillTotal"/>
</span>
<span>
<input type="button" name="addBillDetails" value="Add bill items" id="addBillDetails"/>
</span>
</div>
<div id="bill2" class="bill hide withPadding">
<h3>Bill 2</h3>
<span>
<label>Bill no</label>
<input type="text" name="billNo" class="textField" id="BillNo"/>
</span>
<span>
<label>Bill total</label>
<input type="text" name="billTotal" class="textField" id="BillTotal"/>
</span>
<span>
<input type="button" name="addBillDetails" value="Add bill items" id="addBillDetails"/>
</span>
</div>
<script type="text/javascript">
$(document).ready(function() {
$("input#addBillDetails").live('click',function(){
alert($(this).siblings("#BillNo").val()); …Run Code Online (Sandbox Code Playgroud) 我知道缓存经常使用的sql语句的结果集对于我在搜索有关在java中缓存sql结果集的最佳方法的性能更好.我找到了一些代码但是,它需要向netbeans添加新的jar文件.任何人都可以帮助我如何做到这一点,而无需额外的api?
我写这个声明在所有情况下都能正常工作,除了一个案例
SELECT p.priv_no FROM osqs_privileges p,osqs_users_privileges up
WHERE up.priv_no = p.priv_no AND up.user_no = 54 AND up."GRANT" = 'Y'
UNION
SELECT p.priv_no FROM
osqs_privileges p,osqs_groups_privileges gp,osqs_users_groups ug,osqs_users_privileges up
WHERE gp.priv_no = p.priv_no AND ug.grp_no = gp.grp_no AND ug.user_no = 54
AND gp.priv_no NOT IN
(SELECT priv_no FROM osqs_users_privileges WHERE user_no = 54 AND "GRANT" = 'N');
Run Code Online (Sandbox Code Playgroud)
在osqs_users_privileges没有行的情况下,此语句(SELECT priv_no FROM osqs_users_privileges WHERE user_no = 54 AND"GRANT"='N')返回0行,即使其他语句返回数据,所有脚本也返回0行.为什么?
我想使用.live函数自动完成,但它给出了语法错误
$("input[name=point]").live(function() {
$(this).autocomplete({
minLength:0, //for local data
delay:0, //for local data
source:function(request,response){
//var param= {"action":"getSalePoints"};
$.getJSON("controllers/Order.controller.php?action=getSalePoints",request,function(result){
//create array for response objects
var suggestions = [];
//process response
$.each(result, function(i, val){
//alert(val.number);
suggestions.push(val.number);
});
//pass array to callback
response(suggestions);
});
},
select: function( event, ui ) {
var param={
"action":"getSalePointNo",
"point":ui.item.value
};
$.getJSON("controllers/Order.controller.php",param,function(result){
if(result == "0"){
$('#resultMsg').attr('class','errorMsg');
}
else{
alert(result);
$('[name=pointNo]', $(this).parents(".bill")).val(no);
}
});
}
});
});
Run Code Online (Sandbox Code Playgroud) 我知道文本编辑器无法读取二进制文件,只能由程序读取.但是当我使用java(字节)创建二进制文件时,我可以打开文件并读取它吗?为什么会这样?换句话说,我看到一个纯文本而不是一系列零和一个.我知道在java中有基于字节的流和基于字符的流.当我使用基于字节的流(如FileOutputStream)时,输出是字符而不是字节.
File file = new File("Myfile.dat"); // .txt or .bin
FileOutputStream fos = new FileOutputStream(file);
String data = "Hello, world";
fos.write(data.getBytes());
fos.close();
Run Code Online (Sandbox Code Playgroud)
当我使用记事本打开Myfile.dat时,我希望看到特殊字符或0和1但我可以阅读内容"hello world".所以我不清楚基于字节的流如何以二进制格式存储字符?
java ×5
jquery ×4
oracle11g ×2
sql ×2
attachment ×1
autocomplete ×1
binaryfiles ×1
caching ×1
elements ×1
email ×1
inputstream ×1
json ×1
live ×1
outputstream ×1
php ×1
plsql ×1
servlets ×1
siblings ×1
sockets ×1