我花了一些时间在维基百科的这个Bridge模式示例中,但是,我仍然不明白这个桥模式试图解释什么.
interface DrawingAPI {
public void drawCircle(double x, double y, double radius);
}
/** "ConcreteImplementor" 1/2 */
class DrawingAPI1 implements DrawingAPI {
public void drawCircle(double x, double y, double radius) {
System.out.printf("API1.circle at %f:%f radius %f\n", x, y, radius);
}
}
/** "ConcreteImplementor" 2/2 */
class DrawingAPI2 implements DrawingAPI {
public void drawCircle(double x, double y, double radius) {
System.out.printf("API2.circle at %f:%f radius %f\n", x, y, radius);
}
}
/** "Abstraction" */
interface Shape {
public void draw(); … 我有一个关于使用Servlet和JDBC的一般性问题.
例如,我有一个名为MyDatabaseManager的类,它提供了函数
public boolean updateUser(User user) {...}
public boolean deleteUser(User user) {...}
public boolean inserUser(User user){...}
,这些函数将访问和操作数据库.
我的问题是关于Servlet的实现.我用三个Servlet的(UpdateUserServlet,InsertUserServlet和DeleteUserServlet)的时刻和每一个servlet调用MyDatabaseManager实例(只有一个实例在这里,使用Singleton模式)功能.(例如,UpdateUserServlet调用MyDatabaseManager.updateUser ...).
我认为这是使用Servlet和数据库最直接的方式.但我不确定这是否是正确的做法.例如,如何在行业中实施.
如何将org.docx4j.openpackaging.packages.WordprocessingMLPackage实例保存到ByteArrayInputStream中,然后可以从服务器下载.
谢谢.
对不起,如果之前已经问过这个问题.
我有一个Amazon实例(Ubuntu Server 12.04.1 LTS)并安装了Tomcat版本(Apache Tomcat/6.0.36).它在端口80上按预期工作,但不在端口8080上工作.(不工作意味着"无法连接到Web应用程序管理器").
22 (SSH) 0.0.0.0/0 Delete 80 (HTTP) 0.0.0.0/0 Delete 8080 (HTTP*) 0.0.0.0/0 Delete
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" address="0.0.0.0"/>
在server.xml并添加
JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true" echo $JAVA_OPTS
到setenv.sh
Runnung netstat -ln给了我
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN tcp6 0 0 :::22 :::* LISTEN udp …
我正在实现我目前的第一个GWT应用程序,我只是在创建复杂的自定义小部件时有一个关于Extends Composite和Extend指定小部件之间差异的快速问题,以及使用"extends Composite"的优点.
此外,通过扩展Composite创建的窗口小部件是否可以更快地加载以扩展实际窗口小部件,以及哪些窗口更轻?
谢谢,
我有一个与数据库通信的servlet然后返回一个有序(ORDER BY时间)对象的列表.在servlet部分,我有
//access DB, returns a list of User objects, ordered
ArrayList users = MySQLDatabaseManager.selectUsers();
//construct response
JSONObject jsonResponse = new JSONObject();
int key = 0;
for(User user:users){
log("Retrieve User " + user.toString());
JSONObject jsonObj = new JSONObject();
jsonObj.put("name", user.getName());
jsonObj.put("time", user.getTime());
jsonResponse.put(key, jsonObj);
key++;
}
//write out
out.print(jsonResponse);
从日志中我可以看到数据库以正确的顺序返回User对象.
在前端,我有
success: function(jsonObj){
var json = JSON.parse(jsonObj);
var id = 0;
$.each(json,function(i,item) {
var time = item.time;
var name = item.name;
id++;
$("table#usertable tr:last").after('<tr><td>' + id + '</td … 如何删除bash文件中只出现一次的行?
例如,文件foo.txt具有:
1
2
3
3
4
5
Run Code Online (Sandbox Code Playgroud)
仅处理完文件后
3
3
Run Code Online (Sandbox Code Playgroud)
会保持.
请注意,文件已经排序.
我只是有一个关于如何获取包含十六进制数字的文件长度的快速问题.例如:
724627916C
Run Code Online (Sandbox Code Playgroud)
我能想到的唯一方法是将十六进制值转换为二进制:
724627916C => 0111001001000110001001111001000101101100
Run Code Online (Sandbox Code Playgroud)
然后计算二进制值的位数.只是想知道这是否正确?谢谢
我正在尝试将一些内联汇编写入C.我有两个数组作为输入,我需要的是将array1中的一个元素复制到array2中,以下是我目前所拥有的:
asm (
"movl %0,%%eax;"
"movl %1,%%ebx;"
"movl (%%eax),%%ecx;"
"movl %%ecx,(%ebx);"
"xor %%ecx,%%ecx;"
"movl 4(%%eax),%%ecx;"
//do something on %ecx
"movl %%ecx,4(%ebx);" //write second
:
:"a"(array1),"b"(array2)
);
Run Code Online (Sandbox Code Playgroud)
为什么我会出现分段错误?
我正在寻找我的Sentence Splitter应用程序的测试文件,我希望该文件可以涵盖尽可能多的案例.
谢谢!
我有一些问题要将消息从后台页面传递给我的content_script.js.我希望有人可以指出我错在哪里.
background.html
//in a function
function myFunction() {
chrome.tabs.create({"url":"myurl","selected":true},function(tab){
updateTab(tab.id);
});
}
//update Created new tab
function updateTab(tabId){
chrome.tabs.getSelected(null, function(tab) {
makeRequest(tab.id);
});}
//make request
function makeRequest(tabId) {
chrome.tabs.sendRequest(tabId, {greeting: "hello"}, function(response) {
console.log(response.farewell);
});
}
content_script.js
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
console.log(sender.tab ?
"from a content script:" + sender.tab.url :
"from the extension");
if (request.greeting == "hello")
sendResponse({farewell: "goodbye"});
else
sendResponse({}); // snub them.
});
的manifest.json
"permissions": [
"tabs","notifications","http://*/*"
],
"content_scripts": [
{
"matches": ["http://*/*","https://*/*"],
"js": ["content_script.js"]
}],
我的问题是来自background.html的请求从未传递给content_script.js.我认为创建新选项卡和选择该选项卡的顺序一定存在一些问题,但我不知道如何解决这个问题.谢谢. …
我有以下序列
ubuntu@ip-10-63-3-254:/mnt$ 导出 JAVA_OPTS=-Dmt.config.from=En ubuntu@ip-10-63-3-254:/mnt$ echo $JAVA_OPTS -Dmt.config.from=En ubuntu@ip-10-63-3-254:/mnt$ javac hello.java ubuntu@ip-10-63-3-254:/mnt$ java 你好 mt.config.from=null ubuntu@ip-10-63-3-254:/mnt$ java -Dmt.config.from=En 你好 mt.config.from=En ubuntu@ip-10-63-3-254:/mnt$
哪里你好.java
公开课你好{
公共静态无效主(字符串 [] args){
String property = "mt.config.from";
字符串值 = System.getProperty(property);
System.out.println(property + "=" + value);
}
}
为什么我的导出 JAVA_OPTS=-Dmt.config.from=En 没有被 hello.java 选中?谢谢