c++ WH_GETMESSAGE 钩子 ,勾住程序,但是回调函数没执行,请教

需要拦截目标程序的显示和关闭窗口消息。照搬网上的代码。显示注入DLL成功。但是回调函数并没有执行。请教


#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
HHOOK hooker;
HWND notepadhandle;
BOOL handled;
extern "C" __declspec(dllexport) LRESULT CALLBACK HookProc(int nCode,WPARAM wParam,LPARAM lParam);
char* ConvertInttoChar(int i);
BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
{
    if(ul_reason_for_call==DLL_PROCESS_ATTACH)
    {
        handled=FALSE;
        notepadhandle=FindWindow(TEXT("Notepad"),NULL);

        if(notepadhandle==NULL)
        {
            printf("Notepad Not Found.\n");
            return TRUE;
        }
        hooker=SetWindowsHookEx(WH_GETMESSAGE,HookProc,(HINSTANCE)hModule,GetWindowThreadProcessId(notepadhandle,NULL));
        if(hooker)
        {
            OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE,(DWORD)notepadhandle);
            printf("hookpro:%d\n",HookProc);
            printf("hmodule:%d\n",hModule);
            printf("pid:%d\n",notepadhandle);
            printf("Hook Successfully.\nHookID:%d\n",hooker);
        }
        else
        {
            printf("Hook Failed.\nError:%d\n",GetLastError());
            return TRUE;
        }
        //PostMessage(notepadhandle,WM_CLOSE,0,0);
        //printf("发送关闭指令");

    }

    if(ul_reason_for_call==DLL_PROCESS_DETACH)
    {
        UnhookWindowsHookEx(hooker);
        return TRUE;
    }   
    return TRUE;
}
extern "C" __declspec(dllexport) LRESULT CALLBACK HookProc(int nCode,WPARAM wParam,LPARAM lParam)
{
            printf("NCOD111");
    if(nCode<0)
    {
        printf("NCOD<0");
        return CallNextHookEx(hooker,nCode,wParam,lParam);
    }
    tagMSG* msg;
    msg=(tagMSG*)lParam;
    if(nCode==HC_ACTION && (msg->message==WM_CLOSE))
    {
        if(handled==FALSE)
            printf("拦截到消息:%d\n",msg->message);
        handled=TRUE;
        UnhookWindowsHookEx(hooker);
        msg->message=WM_NULL;

        return CallNextHookEx(hooker,nCode,wParam,(LPARAM)msg);
    }
            printf("LAST");
    return CallNextHookEx(hooker,nCode,wParam,lParam);
}

执行的结果,DLLmain的代码能正常执行,并显示注入成功;但是回调函数中的打印代码均没执行,请教。
执行结果
hookpro:1666846815
hmodule:1666777088
pid:4063406
Hook Successfully.
HookID:17567643

3个回答

你应该用全局钩子,第四个参数用0

dwThreadId [in]
Type: DWORD
The identifier of the thread with which the hook procedure is to be associated. For desktop apps, if this parameter is zero, the hook procedure is associated with all existing threads running in the same desktop as the calling thread. For Windows Store apps, see the Remarks section.

https://msdn.microsoft.com/en-us/library/ms644990(VS.85).aspx

hooker=SetWindowsHookEx(WH_GETMESSAGE,HookProc,(HINSTANCE)hModule,0);


qq_25646935
qq_25646935 回复vencon_s: #include <stdio.h> #include <windows.h> int main(){ LoadLibrary("notehook.dll"); getchar();//这里getchar是为了防止程序退出,若程序过快退出,钩子可能没有效果 return 1; }
接近 4 年之前 回复
qq_25646935
qq_25646935 回复vencon_s: 我的main函数是这样的:
接近 4 年之前 回复
qq_25646935
qq_25646935 回复vencon_s: 请问你的main函数是什么呢?我用32位出现了同样的问题,用x64 报错1>LINK : fatal error LNK1561: entry point must be defined,提前谢谢!
接近 4 年之前 回复
vencon_s
vencon_s 谢谢回复,原因找到了。我编译的代码是32位的,写字板默认64位。这里出了错。重新编译64位没有问题。
4 年多之前 回复
vencon_s
vencon_s 回复oyljerry: 确认是发送了消息的,我在执行程序里面写了段发送消息的代码。发送消息后被注入的剪贴板是能收到消息的,会有关闭提示。我最初认为是发送消息过早程序反映不过来,后来我手动发送消息仍然不能执行回调函数。但是被注入的剪贴板会执行wm_close消息关闭。
4 年多之前 回复
oyljerry
oyljerry 回复vencon_s: 先看有没有发送消息。
4 年多之前 回复
vencon_s
vencon_s 改为全局钩子,我也试过。回调函数hookproc内的语句仍然不能执行。按道理只要有postmessage消息,回调函数就会一直执行printf(“NCOD111”)这句代码,但是程序没有执行这句代码。
4 年多之前 回复

继续求人帮忙解决,

你获取的线程ID不对,貌似那个函数不行,你可以用工具查看一下你程序获得的跟工具获得的是否一样

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
c++ WH_GETMESSAGE 钩子 ,勾住程序,但是回调函数没执行,请教
需要拦截目标程序的显示和关闭窗口消息。照搬网上的代码。显示注入DLL成功。但是回调函数并没有执行。请教 ``` #include "stdafx.h" #include <stdio.h> #include <stdlib.h> HHOOK hooker; HWND notepadhandle; BOOL handled; extern "C" __declspec(dllexport) LRESULT CALLBACK HookProc(int nCode,WPARAM wParam,LPARAM lParam); char* ConvertInttoChar(int i); BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) { if(ul_reason_for_call==DLL_PROCESS_ATTACH) { handled=FALSE; notepadhandle=FindWindow(TEXT("Notepad"),NULL); if(notepadhandle==NULL) { printf("Notepad Not Found.\n"); return TRUE; } hooker=SetWindowsHookEx(WH_GETMESSAGE,HookProc,(HINSTANCE)hModule,GetWindowThreadProcessId(notepadhandle,NULL)); if(hooker) { OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE,(DWORD)notepadhandle); printf("hookpro:%d\n",HookProc); printf("hmodule:%d\n",hModule); printf("pid:%d\n",notepadhandle); printf("Hook Successfully.\nHookID:%d\n",hooker); } else { printf("Hook Failed.\nError:%d\n",GetLastError()); return TRUE; } //PostMessage(notepadhandle,WM_CLOSE,0,0); //printf("发送关闭指令"); } if(ul_reason_for_call==DLL_PROCESS_DETACH) { UnhookWindowsHookEx(hooker); return TRUE; } return TRUE; } extern "C" __declspec(dllexport) LRESULT CALLBACK HookProc(int nCode,WPARAM wParam,LPARAM lParam) { printf("NCOD111"); if(nCode<0) { printf("NCOD<0"); return CallNextHookEx(hooker,nCode,wParam,lParam); } tagMSG* msg; msg=(tagMSG*)lParam; if(nCode==HC_ACTION && (msg->message==WM_CLOSE)) { if(handled==FALSE) printf("拦截到消息:%d\n",msg->message); handled=TRUE; UnhookWindowsHookEx(hooker); msg->message=WM_NULL; return CallNextHookEx(hooker,nCode,wParam,(LPARAM)msg); } printf("LAST"); return CallNextHookEx(hooker,nCode,wParam,lParam); } ``` 执行的结果,DLLmain的代码能正常执行,并显示注入成功;但是回调函数中的打印代码均没执行,请教。 执行结果 hookpro:1666846815 hmodule:1666777088 pid:4063406 Hook Successfully. HookID:17567643
vb 请大神解释下勾子的用法以及各Id勾子,真心不懂
Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" _ (ByVal idHook As Long, _ ByVal lpfn As Long, _ ByVal hmod As Long, _ ByVal dwThreadId As Long) As Long 这几种勾子怎么用,最好有完整的代码演示, Public Const WH_CALLWNDPROC = 4 Public Const WH_CALLWNDPROCRET = 12 Public Const WH_CBT = 5 Public Const WH_DEBUG = 9 Public Const WH_FOREGROUNDIDLE = 11 Public Const WH_GETMESSAGE = 3 Public Const WH_HARDWARE = 8 Public Const WH_JOURNALPLAYBACK = 1 Public Const WH_JOURNALRECORD = 0 Public Const WH_KEYBOARD = 2 Public Const WH_MOUSE = 7 Public Const WH_MSGFILTER = (-1) Public Const WH_SHELL = 10 Public Const WH_SYSMSGFILTER = 6
小程序支付完之后通知回调接受失败
已经支付成功,但是回调函数得时候出错 ![图片说明](https://img-ask.csdn.net/upload/201911/15/1573750656_515862.png) ![图片说明](https://img-ask.csdn.net/upload/201911/15/1573750690_159856.png) yml回调域名配置 ![图片说明](https://img-ask.csdn.net/upload/201911/15/1573750784_858.png) 回调代码 ``` public void notify(HttpServletRequest request, HttpServletResponse response) throws IOException { String wxRetXml = PaymentUtils.getRequestData(request); Map<String, String> wxRetMap = PaymentUtils.xmlToMap(wxRetXml); Assert.notNull(wxRetMap, ExceptionMessage.XML_DATA_INCORRECTNESS.getMessage()); // 当返回的return_code为SUCCESS则回调成功 if ("SUCCESS".equalsIgnoreCase(wxRetMap.get("return_code"))) { // 通知微信收到回调 String resXml = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>"; BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); out.write(resXml.getBytes()); out.flush(); out.close(); // TODO 保存订单流水 具体细节待实现 // orderBillService.save(new OrderBill()); log.info("notify success"+"通知结束"); } else { log.error("notify failed"); } } ``` 小程序代码 ``` wx.request({ url: 'http://127.0.0.1:8080/api/wx/pay/notify', method: 'GET', header: { 'Authorization': 'bearer ' + this.data.token.data.access_token, "Content-Type": "application/x-www-form-urlencoded" }, success: res => { console.log('支付完成后返回的', res) } }) ```
其他软件窗口Edit 自动完成功能实现
实现方法: 1.键盘钩子WH_CALLWNDPROC捕获Edit WM_COMMAND EN_CHANGE 消息 2.WH_GETMESSAGE捕获输入法消息解决中文 和WM_CHAR消息不经输入法的英文字符 3.编辑框中使用IAutoComplete接口 以上方法用哪种方法更好。是否有Demo谢谢
win32程序怎么连接数据库并验证正确性
###运行后虽然有界面出现,但是输入了用户名和密码后就卡住了一会,然后退出了,messagebox也没有显示,求大佬点拨,下面是代码: ``` #include <windows.h> #include "resource.h" //....... //资源 BOOL REGISTEWIN(HINSTANCE hInstance,LPSTR lpClassName, WNDPROC wndProc); void SHOWWND(HWND hwnd); void MESSAGE(); void Link(); LRESULT CALLBACK MYPROC(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam); LRESULT CALLBACK SCREEAN1PROC(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam); LRESULT CALLBACK DialogProc1(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam); BOOL Check(SQLHSTMT hStmt); HWND hwndup; HWND hwnd; RETCODE retcode; HINSTANCE hInstance; SQLHENV henv = SQL_NULL_HENV; SQLHDBC hdbc1 = SQL_NULL_HDBC; SQLHSTMT hstmt1 = SQL_NULL_HSTMT; char users[255]={0}; char password[255]={0}; //winmain主程序 int WinMain(HINSTANCE hInstance,HINSTANCE hinstance,LPSTR lpCmdLine,int nShowCmd){ char* name = "name"; char* screen1 = "screen1"; //创建对话框,并判断对话框是否注册成功 HWND hdlg = CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DIALOG2),GetDesktopWindow(),(DLGPROC)DialogProc1); if(!hdlg) MessageBox(hwnd,"error","error",MB_OK); SHOWWND(hdlg); //创建管理界面 hwndup = CreateWindow(screen1,TEXT("图书管理界面"),WS_OVERLAPPEDWINDOW,500,100,500,700,NULL,LoadMenu(hInstance,MAKEINTRESOURCE(IDR_MENU1)),hInstance,NULL) ; MESSAGE(); return 0; } //DialogProc1函数 LRESULT CALLBACK DialogProc1(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam){ switch (msg) { case WM_INITDIALOG: return TRUE; case WM_COMMAND: { switch (LOWORD(wparam)) { case IDOK: { HWND h1=NULL; HWND h2=NULL; h1=GetDlgItem(hdlg,0x00009c40) ; h2=GetDlgItem(hdlg,0x00009c41) ; if(h1==NULL&&h2==NULL) printf("GetDlgItem fail!"); //获得user和password SendMessage(h1,WM_GETTEXT,255,(LPARAM)users); SendMessage(h2,WM_GETTEXT,255,(LPARAM)password); printf("%s %s\n",users,password); // // //就是这里,,,,想通过数据库查找user和password // // if(Check(hdlg)==TRUE) MessageBox(hdlg,"error","账户或密码不正确",MB_OK); DestroyWindow(hdlg); hdlg = NULL; hdlg = CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),hwnd,(DLGPROC)DialogProc1); ShowWindow(hdlg,SW_SHOW); } break; case IDCANCEL: { //点击取消按钮关闭对话框,最后关闭窗口 EndDialog(hdlg, IDCANCEL); } break; } } break; case WM_SYSCOMMAND: { if (wparam == SC_CLOSE) { EndDialog(hdlg,TRUE); } } break; } return (INT_PTR)FALSE; } //检查user和password函数 BOOL Check(SQLHSTMT hStmt) { Link(); char * person1 = "select *from Login where users='"; const char * person2 = "' and password="; strcat(person1,users); strcat(person1,person2); strcat(person1,password); SQLRETURN ret = SQLExecDirect(hStmt,(SQLCHAR*)person1,strlen(person1)); if (ret == SQL_SUCCESS) return TRUE; else return FALSE; } void MESSAGE(){ MSG msg = {0}; while(GetMessage(&msg,NULL,0,0)){ TranslateMessage(&msg); DispatchMessage(&msg);//分发消息,将消息分发给回调函数,回调函数callback处理完后,返回给dispatchmessage函数,再继续进行消息循环 } } void Link(){ // UCHAR szDSN[SQL_MAX_DSN_LENGTH+1] = "db_mrbm",//数据源名称 szUID[MAXNAME] = "sa", szAuthStr[MAXNAME] = "0922"; //1.连接数据源 //1.环境句柄 retcode = SQLAllocHandle(SQL_HANDLE_ENV,NULL,&henv); retcode = SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3,SQL_IS_INTEGER); //2.连接句柄 retcode = SQLAllocHandle(SQL_HANDLE_DBC,henv, &hdbc1); retcode = SQLConnect(hdbc1, szDSN, 13, szUID, 2, szAuthStr,4); //判断连接是否成功 if((retcode!=SQL_SUCCESS)&&(retcode!=SQL_SUCCESS_WITH_INFO)){ MessageBox(hwnd,"连接错误","error",MB_OK); }else{printf("连接!/n");} // } ```
求助,win32程序不显示窗口
求助大神,为什么这段代码运行不显示窗口,但是任务管理器里面显示这个程序正在运行? ``` #include<windows.h> #define WINDOW_WIDTH 800 #define WINDOW_HEIGHT 600 #define WINDOW_TITLE TEXT("我的游戏程序") #define CLASS_NAME TEXT("CLASS_NAME") LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam); int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int iCmdShow) { WNDCLASSEX wndclass = {0}; wndclass.cbSize = sizeof(WNDCLASSEX); wndclass.style = CS_HREDRAW | CS_HREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); wndclass.hCursor = LoadCursor(NULL,IDC_ARROW); wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wndclass.lpszMenuName = NULL; wndclass.lpszClassName = TEXT("CLASSNAME"); if (!RegisterClassEx(&wndclass)) { return -1; } HWND hwnd = CreateWindow(CLASS_NAME, WINDOW_TITLE, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL); //MoveWindow(hwnd,250,80,WINDOW_WIDTH,WINDOW_HEIGHT,1); ShowWindow(hwnd,iCmdShow); UpdateWindow(hwnd); MSG msg = {0}; /*while (msg.message != WM_QUIT) { if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } }*/ while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } UnregisterClass(CLASS_NAME,wndclass.hInstance); return 0; } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_DESTROY: PostQuitMessage(0); break; default:return DefWindowProc(hwnd,msg,wParam,lParam); } return DefWindowProc(hwnd, msg, wParam, lParam); } ```
websocket心跳重连失败,回调了onOpen后立刻onClose
``` var urlHead = "http://127.0.0.1:8081";//请求接口url头部 var webSoketHead = "127.0.0.1:8081";//soket链接ip+端口号+项目名称 var userId=loginAccount.accountId; var webSoketUrl = "ws://" + webSoketHead + "/LLWS/"+userId; var socket = null; // 判断当前浏览器是否支持WebSocket if ('WebSocket' in window) { socket = new WebSocket(webSoketUrl); } else { alert('该浏览器不支持本系统即时通讯功能,推荐使用谷歌或火狐浏览器!'); } var id = setInterval(function(){ console.log("心跳连接"); var heartMessage={ "to":{ "id":userId, "type":"heartContent" } } try{ if(socket.readyState != 3){ socket.send(JSON.stringify(heartMessage)); //发送消息倒Socket服务 }else{ heartContent(); init(); socket.send(JSON.stringify(heartMessage)); } }catch(err){ console.log(err); setTimeout(function(){ socket.send(JSON.stringify(heartMessage)); }, 5000); } }, 30000) function heartContent(){ // socket.close(); socket = new WebSocket(webSoketUrl); } function init(){ layui.use('layim', function(layim){ // 连接发生错误的回调方法 socket.onerror = function(res) { console.log("llws连接失败!"); // heartContent(); // init(); }; // 连接成功建立的回调方法 socket.onopen = function(event) { console.log("llws连接成功!"); } // 接收到消息的回调方法 socket.onmessage = function(res) { // console.log("llws收到消息啦:" +res.data); if(res.data == "保持连接中"){ heartCheck.reset(); }else{ res = eval("("+res.data+")"); if(res.type == 'friend' || res.type == 'group'){ layim.getMessage(res); }else{ layim.setFriendStatus(res.id,res.content); } } } // 连接关闭的回调方法 socket.onclose = function(res) { console.log("llws关闭连接!"); // heartContent(); // init(); } }); } ```![图片说明](https://img-ask.csdn.net/upload/201911/15/1573782215_619011.png) ![图片说明](https://img-ask.csdn.net/upload/201911/15/1573782298_769696.png) 服务器刚重启的时候一切都是正常的,时间长了几个小时后吧大概,就出现了readyState永远是3不会变成1了 服务端不断进入@onError ![图片说明](https://img-ask.csdn.net/upload/201911/15/1573782654_761023.png) 求大神解决!
win32创建了菜单资源但是没有显示出来
#include <windows.h> #include <commctrl.h> #include <stdio.h> #include "resource.h" #define CUR 0x1111 //新鼠标的id号 #define IDR_MENU 0x0999 LRESULT CALLBACK MYPROC(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){ switch(msg){ case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd,msg,wparam,lparam); } int WinMain(HINSTANCE hInstance,HINSTANCE hinstance,LPSTR lpCmdLine,int nShowCmd){ char* name = "name"; WNDCLASS wc = {0}; MSG msg; HWND hwnd; wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.hInstance = hInstance; wc.lpfnWndProc = MYPROC; wc.lpszClassName = name; wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU); wc.hCursor = LoadCursor(hInstance,MAKEINTRESOURCE(CUR));//鼠标样式的资源 RegisterClass(&wc); hwnd = CreateWindowExA(WS_EX_CLIENTEDGE,name,TEXT("登陆界面"),WS_OVERLAPPEDWINDOW,500,100,500,700,NULL,LoadMenu(hInstance,MAKEINTRESOURCE(IDR_MENU)),hInstance,NULL); ShowWindow(hwnd,nShowCmd); UpdateWindow(hwnd); while(GetMessage(&msg,NULL,0,0)){ TranslateMessage(&msg); DispatchMessage(&msg);//分发消息,将消息分发给回调函数,回调函数callback处理完后,返回给dispatchmessage函数,再继续进行消息循环 } return msg.message; } #编译没错,但是显示不出来菜单栏,求大神解答~
spring boot 2.1.1,@Transactional注释无法启动事务回滚
``` @Transactional public BooleanMessage importUserOne(String ppUserId) { deleteOneUser(ppUserId); transferOneUser(ppUserId); return BooleanMessage.getSuccessMessage("同步成功!"); } @Transactional public void deleteOneUser(String userid) { try { // 删除:用户 this.deleteUsers(userid); } catch (Exception e) { throw new RuntimeException("delete error : "+e.getMessage()); } } public void deleteUsers(String userid) { dd用户Service.delete(userid); } public boolean delete(String ppUserId) { return ddMapper.deleteByPrimaryKey(ppUserId) == 1; } @Transactional public void transferOneUser(String userid) { try { // 迁移:用户 dd用户Service.transferUsers(findOne(userid)); } catch (Exception e) { throw new RuntimeException("transferOneUser error : "+e.getMessage()); } } @Transactional public void transferUsers(Users one) { if (one == null) { throw new NullPointerException("Users is null!"); } try { String userid = one.getUserid() == null ? "" : one.getUserid(); 用户 mm用户 = new 用户(); mm用户.set用户id(userid); this.add(mm用户); } catch (Exception e) { throw new RuntimeException("users add error : "+e.getMessage()); } } public boolean add(用户 mm用户) { return ddMapper.insert(mm用户) == 1; } ``` ``` import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; import org.springframework.context.annotation.ComponentScan; @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class,DataSourceTransactionManagerAutoConfiguration.class, MybatisAutoConfiguration.class}) @SpringBootApplication @ComponentScan(basePackages={"importdata.*"}) public class BshImportdataApplication { public static void main(String[] args) { SpringApplication.run(BshImportdataApplication.class, args); } } ```我在spring boot 2.1.1版本中,在service层中的方法上加上@Transactional的注解, 没办法启动这个方法的事务回滚,里面的方法执行一半出错也不会回滚成没执行之前的一样,求大神解决
excel2016 64bit的vba中使用API函数RegisterClass注册窗体类就Excel就崩溃
excel2016 64bit的vba中使用API函数RegisterClass注册窗体类就Excel就崩溃!请问是怎么回事? ``` Option Explicit Public Declare PtrSafe Function RegisterClass Lib "user32" Alias "RegisterClassA" (Class As WNDCLASS) As Long Public Declare PtrSafe Function UnregisterClass Lib "user32" Alias "UnregisterClassA" (ByVal lpClassName As String, ByVal hInstance As Long) As Long Public Declare PtrSafe Function DefWindowProc Lib "user32" Alias "DefWindowProcA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Public Declare PtrSafe Function GetMessage Lib "user32" Alias "GetMessageA" (lpMsg As Msg, ByVal hwnd As Long, ByVal wMsgFilteRmin As Long, ByVal wMsgFilterMax As Long) As Long Public Declare PtrSafe Function TranslateMessage Lib "user32" (lpMsg As Msg) As Long Public Declare PtrSafe Function DispatchMessage Lib "user32" Alias "DispatchMessageA" (lpMsg As Msg) As Long Public Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Public Declare PtrSafe Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Any) As Long Public Declare PtrSafe Function LoadIcon Lib "user32" Alias "LoadIconA" (ByVal hInstance As Long, ByVal lpIconName As String) As Long Public Declare PtrSafe Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long Public Declare PtrSafe Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Public Declare PtrSafe Function SetWindowLongPtr Lib "user32" Alias "SetWindowLongPtrA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Public Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Public Declare PtrSafe Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long Public Declare PtrSafe Function PostQuitMessage Lib "user32" (ByVal nExitCode As Long) Public Declare PtrSafe Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOPENFILENAME As OPENFILENAME) As Long Public Declare PtrSafe Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOPENFILENAME As OPENFILENAME) As Long Public Declare PtrSafe Function GetLastError Lib "kernel32" () As Long Public Type OPENFILENAME lStructSize As Long hwndOwner As Long hInstance As Long lpstrFilter As String lpstrCustomFilter As String nMaxCustFilter As Long nFilterIndex As Long lpstrFile As String nMaxFile As Long lpstrFileTitle As String nMaxFileTitle As Long lpstrInitialDir As String lpstrTitle As String flags As Long nFileOffset As Integer nFileExtension As Integer lpstrDefExt As String lCustData As Long lpfnHook As Long lpTemplateName As String End Type Public Const OFN_OVERWRITEPROMPT = &H2 Public Const OFN_HIDEREADONLY = &H4 Public Const OFN_PATHMUSTEXIST = &H800 Public Const OFN_FILEMUSTEXIST = &H1000 Public Type WNDCLASS style As Long lpfnwndproc As LongPtr cbClsextra As Long cbWndExtra2 As Long hInstance As LongPtr hIcon As Long hCursor As Long hbrBackground As Long lpszMenuName As String lpszClassName As String End Type Public Type POINTAPI x As Long y As Long End Type Public Type Msg hwnd As Long message As Long wParam As Long lParam As Long time As Long pt As POINTAPI End Type Public Const CS_VREDRAW = &H1 Public Const CS_HREDRAW = &H2 Public Const CW_USEDEFAULT = &H80000000 Public Const ES_MULTILINE = &H4& Public Const WS_BORDER = &H800000 Public Const WS_CHILD = &H40000000 Public Const WS_OVERLAPPED = &H0& Public Const WS_CAPTION = &HC00000 ' WS_BORDER Or WS_DLGFRAME Public Const WS_SYSMENU = &H80000 Public Const WS_THICKFRAME = &H40000 Public Const WS_MINIMIZEBOX = &H20000 Public Const WS_MAXIMIZEBOX = &H10000 Public Const WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX) Public Const WS_EX_CLIENTEDGE = &H200& Public Const COLOR_WINDOW = 5 Public Const WM_DESTROY = &H2 Public Const WM_LBUTTONDOWN = &H201 Public Const WM_LBUTTONUP = &H202 Public Const IDC_ARROW = 32512& Public Const IDI_APPLICATION = 32512& Public Const GWL_WNDPROC = (-4) Public Const SW_SHOWNORMAL = 1 Public Const MB_OK = &H0& Public Const MB_ICONEXCLAMATION = &H30& Public Const gClassName = "MyClassName" Public Const gAppName = "My Window Caption" Public gButOldProc As Long Public gHwnd As Long, gButtonHwnd As Long, gEditHwnd As Long Public Sub Main() Dim wMsg As Msg ''Call procedure to register window classname. If false, then exit. If RegisterWindowClass = False Then Exit Sub ''Create window If CreateWindows Then ''Loop will exit when WM_QUIT is sent to the window. Do While GetMessage(wMsg, 0&, 0&, 0&) ''TranslateMessage takes keyboard messages and converts ''them to WM_CHAR for easier processing. Call TranslateMessage(wMsg) ''Dispatchmessage calls the default window procedure ''to process the window message. (WndProc) Call DispatchMessage(wMsg) Loop End If Call UnregisterClass(gClassName$, Application.hInstance) End Sub Public Function RegisterWindowClass() As Boolean Dim wc As WNDCLASS Dim a As Variant wc.style = CS_HREDRAW Or CS_VREDRAW wc.lpfnwndproc = GetAddress(AddressOf WndProc) ''Address in memory of default window procedure. wc.hInstance = Application.HinstancePtr wc.hIcon = LoadIcon(0&, IDI_APPLICATION) ''Default application icon wc.hCursor = LoadCursor(0&, IDC_ARROW) ''Default arrow wc.hbrBackground = COLOR_WINDOW ''Default a color for window. wc.lpszClassName = gClassName$ RegisterWindowClass = RegisterClass(wc) a = GetLastError Debug.Print RegisterWindowClass & "ERR" Debug.Print CStr(GetLastError()) End Function Public Function CreateWindows() As Boolean ''开始创建窗体 gHwnd& = CreateWindowEx(0&, gClassName$, gAppName$, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 208, 150, 0&, 0&, App.hInstance, ByVal 0&) ''创建一个按钮 gButtonHwnd& = CreateWindowEx(0&, "Button", "Click Here", WS_CHILD, 58, 90, 85, 25, gHwnd&, 0&, App.hInstance, 0&) ''创建一个(WS_EX_CLIENTEDGE、ES_MULTILINE风格的TextBox gEditHwnd& = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", "This is the edit control." & vbCrLf & "As you can see, it's multiline.", WS_CHILD Or ES_MULTILINE, 0&, 0&, 200, 80, gHwnd&, 0&, App.hInstance, 0&) Call ShowWindow(gHwnd&, SW_SHOWNORMAL) Call ShowWindow(gButtonHwnd&, SW_SHOWNORMAL) Call ShowWindow(gEditHwnd&, SW_SHOWNORMAL) gButOldProc& = GetWindowLong(gButtonHwnd&, GWL_WNDPROC) ''Set default window procedure of button to ButtonWndProc. Different ''settings of windows is listed in the MSDN Library. We are using GWL_WNDPROC ''to set the address of the window procedure. Call SetWindowLongPtr(gButtonHwnd&, GWL_WNDPROC, GetAddress(AddressOf ButtonWndProc)) CreateWindows = (gHwnd& <> 0) End Function '窗体运行的主函数,在注册这个窗体时已经指定的 Public Function WndProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Dim strTemp As String Select Case uMsg& Case WM_DESTROY: ''Since DefWindowProc doesn't automatically call ''PostQuitMessage (WM_QUIT). We need to do it ourselves. ''You can use DestroyWindow to get rid of the window manually. Call PostQuitMessage(0&) End Select ''Let windows call the default window procedure since we're done. WndProc = DefWindowProc(hwnd&, uMsg&, wParam&, lParam&) End Function Public Function ButtonWndProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Select Case uMsg& Case WM_LBUTTONUP: Call MessageBox(gHwnd&, "You clicked the button!", App.Title, MB_OK Or MB_ICONEXCLAMATION) End Select ButtonWndProc = CallWindowProc(gButOldProc&, hwnd&, uMsg&, wParam&, lParam&) End Function Public Function GetAddress(ByVal lngAddr As LongPtr) As LongPtr GetAddress = lngAddr End Function ```
eclipse连接不上mysql
之前用的mysql8.0 重装成mysql5.7.28后 eclipse就连接不上了 jar包是:mysql-connector-java-5.1.34-bin.jar 这是测试代码 ``` import java.sql.Connection; import java.sql.DriverManager; public class test1 { public static void main(String[] args) { String driver = "com.mysql.jdbc.Driver"; String URL = "jdbc:mysql://localhost:3306/testphone"; Connection con = null; try { Class.forName(driver); } catch(java.lang.ClassNotFoundException e) { System.out.println("Connect Successfull."); System.out.println("Cant't load Driver"); } try { con=DriverManager.getConnection(URL,"root","123456"); System.out.println("Connect Successfull."); } catch(Exception e) { System.out.println("Connect fail:" + e.getMessage()); } } } ``` 输出信息: ``` Connect fail:Access denied for user 'root'@'localhost' (using password: YES) ``` 我用百度搜索过,这个问题,基本都是一个方法,就是skip-grant-tables,然后修改root的密码 ![图片说明](https://img-ask.csdn.net/upload/202001/04/1578131867_250350.png) 但是我的数据库里有这个用户和密码 而且我用navicat能够连接数据库 ![图片说明](https://img-ask.csdn.net/upload/202001/04/1578131956_896898.png) 求求大神看看
本人是初学者看一些代码有些不懂,还请大神指点一下,谢谢
${ msg }表示什么意思呢??? index.jsp怎么跳转到main.jsp呢??? **index.jsp** ``` <html > <title>聊天室</title> <link href="CSS/style.css" rel="stylesheet"> <script type="text/javascript"> function check(){ if(document.getElementById("form1").username.value==""){ alert("请输入用户名!"); document.getElementById("form1").username.focus(); return false; } if(document.getElementById("form1").password.value==""){ alert("请输入密码名!"); document.getElementById("form1").password.focus(); return false; } } </script> <body> <br> <center><h3 style="color:red;">${ msg }</h3></center> <form id="form1" name="form1" method="post" action="${pageContext.request.contextPath }/user" onSubmit="return check()"> <input type="hidden" name="method" value="login"> <table width="371" height="230" border="0" align="center" cellpadding="0" cellspacing="0" background="images/login.jpg"> <tr> <td height="120" colspan="3" class="word_dark">&nbsp;</td> </tr> <tr> <td width="53" align="center" valign="top" class="word_dark">&nbsp;</td> <td width="216" align="center" valign="top" class="word_dark"> <table width="100%" height="100%"> <tr> <td>用户名:</td> <td><input type="text" name="username" class="login"></td> </tr> </table> </td> <td width="94" valign="top" class="word_dark"></td> </tr> <tr> <td width="53" align="center" valign="top" class="word_dark">&nbsp;</td> <td width="216" align="center" valign="top" class="word_dark"> <table width="100%" height="100%"> <tr> <td>密&nbsp;&nbsp;码:</td> <td><input type="password" name="password" class="login"></td> </tr> </table> </td> <td width="94" valign="top" class="word_dark"></td> </tr> <tr> <td width="53" align="center" valign="top" class="word_dark">&nbsp;</td> <td width="216" align="center" valign="top" class="word_dark"> <input name="Submit" type="submit" class="btn_bg" value="进 入"> </td> <td width="94" valign="top" class="word_dark"> </td> </tr> </table> </form> </body> </html> ``` **main** ``` <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ include file="safe.jsp"%> <html> <head> <title>聊天室</title> <link href="CSS/style.css" rel="stylesheet"> <script type="text/javascript" src="${ pageContext.request.contextPath }/js/jquery-1.8.3.js"></script> <script type="text/javascript"> var sysBBS = "<span style='font-size:14px; line-height:30px;'>欢迎光临心之语聊天室,请遵守聊天室规则,不要使用不文明用语。</span><br><span style='line-height:22px;'>";var sysBBS = "<span style='font-size:14px; line-height:30px;'>欢迎光临心之语聊天室,请遵守聊天室规则,不要使用不文明用语。</span><br><span style='line-height:22px;'>"; window.setInterval("showContent();",1000); window.setInterval("showOnLine();",10000); window.setInterval("check();",1000); // Jquery:JS框架. // 相当于window.onload $(function(){ showOnLine(); showContent(); check(); }); function check(){ $.post("${pageContext.request.contextPath}/user?method=check",function(data){ if(data == 1){ // 提示用户下线了 alert("用户已经被踢下线了!"); // 回到登录页面! window.location = "index.jsp"; } }); } // 显示在线人员列表 function showOnLine(){ // 异步发送请求 获取在线人员列表 // Jquery发送异步请求 $.post("${pageContext.request.contextPath}/online.jsp?"+new Date().getTime(),function(data){ // $("#online") == document.getElementById("online"); $("#online").html(data); }); } // 显示聊天的内容 function showContent(){ $.post("${pageContext.request.contextPath}/user?"+new Date().getTime(),{'method':'getMessage'},function(data){ $("#content").html(sysBBS+data); }); } function set(selectPerson){ //自动添加聊天对象 if(selectPerson != "${existUser.username}"){ form1.to.value=selectPerson; }else{ alert("请重新选择聊天对象!"); } } function send(){ if(form1.to.value==""){ alert("请选择聊天对象!"); return false; } if(form1.content.value==""){ alert("发送信息不可以为空!"); form1.content.focus(); return false; } // $("#form1").serialize():让表单中所有的元素都提交. // jquery提交数据.{id:1,name:aa,age:25} $.post("${pageContext.request.contextPath}/user?"+new Date().getTime(),$("#form1").serialize(),function(data){ $("#content").html(sysBBS+data+"</span>"); }); } function exit(){ alert("欢迎您下次光临!"); window.location.href="${pageContext.request.contextPath}/user?method=exit"; } function checkScrollScreen(){ if(!$("#scrollScreen").attr("checked")){ $("#content").css("overflow","scroll"); }else{ $("#content").css("overflow","hidden"); //当聊天信息超过一屏时,设置最先发送的聊天信息不显示 //alert($("#content").height()); $("#content").scrollTop($("#content").height()*2); } setTimeout('checkScrollScreen()',500); } </script> </head> <body> <table width="778" height="150" border="0" align="center" cellpadding="0" cellspacing="0" background="images/top.jpg"> <tr> <td>&nbsp;</td> </tr> </table> <table width="778" height="276" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="165" valign="top" bgcolor="#f6fded" id="online" style="padding:5px">在线人员列表</td> <td width="613" height="200px" valign="top" background="images/main_bj.jpg" bgcolor="#FFFFFF" style="padding:5px; "> <div style="height:290px; overflow:hidden" id="content">聊天内容</div></td> </tr> </table> <table width="778" height="95" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#D6D3CE" background="images/bottom.jpg"> <form action="" id="form1" name="form1" method="post"> <input type="hidden" name="method" value="sendMessage"/> <tr> <td height="30" align="left">&nbsp;</td> <td height="37" align="left"> <input name="from" type="hidden" value="${existUser.username}">[${existUser.username} ]对 <input name="to" type="text" value="" size="35" readonly="readonly"> 表情 <select name="face" class="wenbenkuang"> <option value="无精打采的">无精打采的</option> </select> 说:</td> <td width="189" align="left">&nbsp;&nbsp;字体颜色: <select name="color" size="1" class="wenbenkuang" id="select"> <option selected>默认颜色</option> <option style="color:#999999" value="999999">烟雨蒙蒙</option> </select> </td> <td width="19" align="left"><input name="scrollScreen" type="checkbox" class="noborder" id="scrollScreen" onClick="checkScrollScreen()" value="1" checked> </td> </tr> <tr> <td width="21" height="30" align="left">&nbsp;</td> <td width="549" align="left"> <input name="content" type="text" size="70" onKeyDown="if(event.keyCode==13 && event.ctrlKey){send();}"> <input name="Submit2" type="button" class="btn_grey" value="发送" onClick="send()"> </td> <td align="right"><input name="button_exit" type="button" class="btn_grey" value="退出聊天室" onClick="exit()"> </td> <td align="center">&nbsp;</td> </tr> <tr> <td height="30" align="left">&nbsp;</td> <td align="center">&nbsp;</td> </tr> </form> </table> </body> </html> ```
获取sql执行错误详细信息
SQLException e.getMessage()得到的异常信息: [KingbaseES JDBC Driver][HY000]批处理执行出错:[KingbaseES Server]ERROR: 类型VARCHAR(9)的值过长 这是一个字段插入sqlServer数据库中的错误,现在没有错误字段名称 我现在想获取字段名称,如何入手解决?
textout 钩子函数为何无法触发
我从网上下了部分代码,写了一个钩子函数获取textout输出内容。一个是包含钩子函数的DLL程序包,另一个应用程序安装了改钩子,调用了TextOut之后。 DLL里的TextOut钩子函数未被调用,请大侠指点一下问题出在哪儿? 附DLL 钩子程序包。 CPP部分: #include "stdafx.h" #include "hook.h" #include "winuser.h" #include <ImageHlp.h> #include <tlhelp32.h> #pragma comment(lib,"ImageHlp") //定义全局共享数据段 #pragma data_seg("Shared") HMODULE hmodDll=NULL; HHOOK hHook=NULL; #pragma data_seg() #pragma comment(linker,"/Section:Shared,rws") //设置全局共享数据段的属性 //dll的入口点 BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch(ul_reason_for_call) { case DLL_PROCESS_ATTACH: break; case DLL_PROCESS_DETACH: break; } hmodDll=hModule; return TRUE; } void WINAPI HookOneAPI(LPCTSTR pszCalleeModuleName,PROC pfnOriginApiAddress, PROC pfnDummyFuncAddress,HMODULE hModCallerModule) { ULONG size; //获取指向PE文件中的Import中IMAGE_DIRECTORY_DESCRIPTOR数组的指针 PIMAGE_IMPORT_DESCRIPTOR pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR) ImageDirectoryEntryToData(hModCallerModule,TRUE,IMAGE_DIRECTORY_ENTRY_IMPORT,&size); if (pImportDesc == NULL) return; //查找记录,看看有没有我们想要的DLL for (;pImportDesc->Name;pImportDesc++) { LPSTR pszDllName = (LPSTR)((PBYTE)hModCallerModule+pImportDesc->Name); if (lstrcmpiA(pszDllName,pszCalleeModuleName) == 0) break; } if (pImportDesc->Name == NULL) return; //寻找我们想要的函数 PIMAGE_THUNK_DATA pThunk = (PIMAGE_THUNK_DATA)((PBYTE)hModCallerModule+pImportDesc->FirstThunk); for (;pThunk->u1.Function;pThunk++) { //ppfn记录了与IAT表项相应的函数的地址 PROC * ppfn= (PROC *)&pThunk->u1.Function; if (*ppfn == pfnOriginApiAddress) { //如果地址相同,也就是找到了我们想要的函数,进行改写,将其指向我们所定义的函数 WriteProcessMemory(GetCurrentProcess(),ppfn,&(pfnDummyFuncAddress), sizeof(pfnDummyFuncAddress),NULL); return; } } } //查找所挂钩的进程所应用的dll模块的 BOOL WINAPI HookAllAPI (LPCTSTR pszCalleeModuleName,PROC pfnOriginApiAddress, PROC pfnDummyFuncAddress,HMODULE hModCallerModule) { if (pszCalleeModuleName == NULL) return FALSE; if (pfnOriginApiAddress == NULL) return FALSE; MEMORY_BASIC_INFORMATION mInfo; HMODULE hModHookDLL; HANDLE hSnapshot; MODULEENTRY32 me = {sizeof(MODULEENTRY32)}; //MODULEENTRY32:描述了一个被指定进程所应用的模块的struct VirtualQuery(HookOneAPI,&mInfo,sizeof(mInfo)); hModHookDLL=(HMODULE)mInfo.AllocationBase; hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,0); BOOL bOk = Module32First(hSnapshot,&me); if (bOk == FALSE) return FALSE; while (bOk) { if (me.hModule != hModHookDLL) { hModCallerModule = me.hModule;//赋值 //me.hModule:指向当前被挂钩进程的每一个模块 HookOneAPI(pszCalleeModuleName,pfnOriginApiAddress, pfnDummyFuncAddress,hModCallerModule); } bOk = Module32Next(hSnapshot,&me); } return TRUE; } //通过使pfnDummyFuncAddress与pfnOriginApiAddress相等的方法,取消对IAT的修改 BOOL WINAPI UnhookAllAPIHooks(LPCTSTR pszCalleeModuleName,PROC pfnOriginApiAddress, PROC pfnDummyFuncAddress,HMODULE hModCallerModule) { PROC temp; temp = pfnOriginApiAddress; pfnOriginApiAddress = pfnDummyFuncAddress; pfnDummyFuncAddress = temp; return HookAllAPI(pszCalleeModuleName,pfnOriginApiAddress, pfnDummyFuncAddress,hModCallerModule); } //钩子子程。与其它钩子子程不大相同,没做什么有意义的事情,继续调用下一个钩子子程,形成循环 LRESULT CALLBACK GetMsgProc(int code,WPARAM wParam,LPARAM lParam) { return CallNextHookEx(hHook,code,wParam,lParam); } void __declspec(dllexport) WINAPI InstallHook(BOOL IsHook,DWORD dwThreadId) { if(IsHook) { hHook=SetWindowsHookEx(WH_GETMESSAGE,(HOOKPROC)GetMsgProc,hmodDll,dwThreadId); //GetProcAddress(GetModuleHandle("GDI32.dll"),"ExtTextOutA"):取得要钩的函数在所在dll中的地址 HookAllAPI("GDI32.dll",GetProcAddress(GetModuleHandle("GDI32.dll"), "TextOutW"),(PROC)&H_TextOutW,NULL); HookAllAPI("GDI32.dll",GetProcAddress(GetModuleHandle("GDI32.dll"), "TextOutA"),(PROC)&H_TextOutA,NULL); } else { UnInstallHook(); //Beep(440,1000); UnhookAllAPIHooks("GDI32.dll",GetProcAddress(GetModuleHandle("GDI32.dll"), "TextOutA"),(PROC)&H_TextOutA,NULL); UnhookAllAPIHooks("GDI32.dll",GetProcAddress(GetModuleHandle("GDI32.dll"), "TextOutW"),(PROC)&H_TextOutW,NULL); } } //卸载钩子 BOOL WINAPI UnInstallHook() { UnhookWindowsHookEx(hHook); return TRUE; } /*======================TextOutA/W 接口函数=========================================*/ BOOL WINAPI H_TextOutA(HDC hdc,int nXStart,int nYStart,LPCSTR lpString,int cbString) { MessageBox(NULL,"textout captured!!!","test",MB_OK); TextOut(hdc,nXStart,nYStart,LPCSTR(lpString),cbString);//返回原来的函数,以显示字符 return TRUE; } BOOL WINAPI H_TextOutW(HDC hdc,int nXStart,int nYStart,LPCSTR lpString,int cbString) { MessageBox(NULL,"TextOutW","APIHook_Dll ---rivershan",MB_OK); TextOut(hdc,nXStart,nYStart,LPCSTR(lpString),cbString);//返回原来的函数,以显示字符 return TRUE; } H文件部分: #ifdef HOOK_EXPORTS #define HOOK_API __declspec(dllexport) #else #define HOOK_API __declspec(dllimport) #endif extern HOOK_API int nHook; HOOK_API int fnHook(void); void __declspec(dllexport) WINAPI InstallHook(BOOL,DWORD); BOOL WINAPI UnInstallHook(); LRESULT CALLBACK GetMsgProC(int code,WPARAM wParam,LPARAM lParam); void WINAPI HookOneAPI(LPCTSTR pszCalleeModuleName,PROC pfnOriginApiAddress, PROC pfnDummyFuncAddress,HMODULE hModCallerModule); BOOL WINAPI HookAllAPI(LPCTSTR pszCalleeModuleName,PROC pfnOriginApiAddress, PROC pfnDummyFuncAddress,HMODULE hModCallerModule); BOOL WINAPI UnhookAllAPIHooks(LPCTSTR pszCalleeModuleName,PROC pfnOriginApiAddress, PROC pfnDummyFuncAddress,HMODULE hModCallerModule); BOOL WINAPI H_TextOutA(HDC, int, int, LPCSTR, int); BOOL WINAPI H_TextOutW(HDC, int, int, LPCSTR, int);
求助:使用的thinkcmf框架,Db事务无法回滚?
各位大佬帮忙看看啊!! 今天使用Db类操作数据库,用到事务的时候怎么也不生效,无法rollback,数据库引擎明明是innoDb,后来自己新建了一个表测试,如下: ``` public function test(){ Db::startTrans(); try{ Db::name('name')->insert(['name'=>'yyyyyy']); throw new \Exception('ERROR'); Db::commit(); } catch(\Exception $e){ Db::rollback(); $this->success($e->getMessage()); } } ``` 测试结果确实走到catch里了,说明rollback是执行了,但是表里依然多了一条数据,实现摸不着头脑,哪位大佬指点下迷津!谢谢啊!!
初始化复选框选中状态会触发本身的OnCheckedChange事件?
各位大佬,请教一下。我在Adapter的getview 方法中 根据获取的值来**初始化复选框**的**选中状态**,然后**这个初始化操作就触发了复选框的onCheckedchange事件**,事件中有刷新数据的功能,然后就进入了死循环。这怎么处理啊 环境:Android studio 3.5.4 下面是初始化操作,在getview 方法中的 ``` BmobQuery<Cai> query_state_cai=new BmobQuery<>(); query_state_cai.addWhereEqualTo("tieZiId",tieziId).addWhereEqualTo("people",userId); query_state_cai.findObjects(new FindListener<Cai>() { @Override public void done(List<Cai> list, BmobException e) { if(e==null){ if(list.size()>0){ viewHolder.check_cai.setChecked(true); }else { viewHolder.check_cai.setChecked(false); } }else { Log.d("print","初始化点赞状态出错:"+e.getMessage()); } } }); ``` 下面是复选框的事件 ``` @Override public void OnCheckChange_Cai(CompoundButton viewButton) { String tieziId=viewButton.getTag().toString(); String userId; MyApplication myApplication=new MyApplication(); //如果用户已登录 if(myApplication.getLoginUser()!=null){ userId= myApplication.getLoginUser().getUserId(); if(viewButton.isChecked()){ //如果单选框被选中,执行操作 delete_zanInfo(tieziId,userId);//删除点赞的记录 saveCAI(tieziId,userId);//添加踩的记录 }else { //如果没选中 delete_caiInfo(tieziId,userId);//删除踩的记录 } initDatas();//重新获取ListView的数据 }else{ Toast.makeText(mContext,"请登录后再操作",Toast.LENGTH_SHORT).show(); } } ```
Java WEB 连接数据库的登录界面失败?
连接数据库是成功的,但是输入用户名和密码后跳转到错误页面 有几段代码不太确定对不对,请帮忙看一看 //login.jsp ``` <form name="form1" method="post" action="manager.do?action=login"> ``` //struts-config.xml ``` <action name="managerForm" path="/manager" scope="request" type="com.action.Manager" validate="true"> <forward name="managerLoginok" path="/main.jsp" /> <forward name="error" path="/error.jsp" /> </action> ``` //Manager.java ``` package com.action; import org.apache.struts.action.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.actionForm.ManagerForm; import com.dao.ManagerDAO; import javax.servlet.http.HttpSession; public class Manager extends Action { private ManagerDAO managerDAO = null; public Manager() { this.managerDAO = new ManagerDAO(); } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { String action = request.getParameter("action"); if (action == null || "".equals(action)) { return mapping.findForward("error"); } else if ("login".equals(action)) { return managerLogin(mapping, form, request, response); } request.setAttribute("error", "操作失败!"); return mapping.findForward("error"); } // 管理员身份验证 public ActionForward managerLogin(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { ManagerForm managerForm = (ManagerForm) form; //将接收到的表单信息强制转换成ActionForm类型 managerForm.setAd_name(managerForm.getAd_name()); managerForm.setAd_pwd(managerForm.getAd_pwd()); int ret = managerDAO.checkManager(managerForm); System.out.print("验证结果ret的值:" + ret); if (ret == 1) { //将登录到系统的管理员名称保存到session HttpSession session = request.getSession(); session.setAttribute("manager", managerForm.getAd_name()); return mapping.findForward("managerLoginok"); } else { request.setAttribute("error", "您输入的管理员名称或密码错误!"); return mapping.findForward("error"); } } } ``` //ConnDB.java ``` //执行查询语句 public ResultSet executeQuery(String sql) { try { conn=getConnection(); stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); rs=stmt.executeQuery(sql); } catch(SQLException ex){ System.err.println(ex.getMessage()); } return rs; } ``` //ManagerDAO.java ``` //管理员身份验证 public int checkManager(ManagerForm managerForm) { int flag = 0; ChStr chStr=new ChStr(); String sql = "SELECT * FROM Ad_info where ad_name='" + chStr.filterStr(managerForm.getAd_name()) + "'"; ResultSet rs = conn.executeQuery(sql); try { if (rs.next()) { String pwd = chStr.filterStr(managerForm.getAd_pwd()); //获取输入的密码并过滤输入字符串中的危险字符 if (pwd.equals(rs.getString(3))) { flag = 1; } else { flag = 0; } }else{ flag = 0; } } catch (SQLException ex) { flag = 0; }finally{ conn.close(); } return flag; } ``` 大概应该是这几段代码的原因,但是不清楚应该怎么修改,请帮忙看一下
maven 工程 install 安装时
# 报错 Exception in thread "main" java.lang.AssertionError at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155) at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46) at jdk.compiler/com.sun.tools.javac.comp.Modules.enter(Modules.java:247) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.readSourceFile(JavaCompiler.java:837) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$ImplicitCompleter.complete(JavacProcessingEnvironment.java:1534) at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:642) at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1326) at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.complete(Type.java:1140) at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.getTypeArguments(Type.java:1066) at jdk.compiler/com.sun.tools.javac.code.Printer.visitClassType(Printer.java:237) at jdk.compiler/com.sun.tools.javac.code.Printer.visitClassType(Printer.java:52) at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.accept(Type.java:993) at jdk.compiler/com.sun.tools.javac.code.Printer.visit(Printer.java:136) at jdk.compiler/com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArgument(AbstractDiagnosticFormatter.java:199) at jdk.compiler/com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArguments(AbstractDiagnosticFormatter.java:167) at jdk.compiler/com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:111) at jdk.compiler/com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:67) at jdk.compiler/com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArgument(AbstractDiagnosticFormatter.java:185) at jdk.compiler/com.sun.tools.javac.util.AbstractDiagnosticFormatter.formatArguments(AbstractDiagnosticFormatter.java:167) at jdk.compiler/com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:111) at jdk.compiler/com.sun.tools.javac.util.BasicDiagnosticFormatter.formatMessage(BasicDiagnosticFormatter.java:67) at jdk.compiler/com.sun.tools.javac.util.JCDiagnostic.getMessage(JCDiagnostic.java:788) at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$DiagnosticSourceUnwrapper.getMessage(ClientCodeWrapper.java:799) at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:131) at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174) at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1075) at org.apache.maven.plugin.compiler.TestCompilerMojo.execute(TestCompilerMojo.java:176) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at org.apache.maven.cli.MavenCli.main(MavenCli.java:192) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347) at org.codehaus.classworlds.Launcher.main(Launcher.java:47) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131) ![图片说明](https://img-ask.csdn.net/upload/201912/23/1577110867_869124.png)
重金求解,为什么我接收不到socket服务端返回的信息,代码如下,这个logger.debug("result:"result)为什么总是空,确认了服务端的确返回到了socket,怎样才能正确从socket取到值呢?
这是socket客户端代码 ``` import java.io.BufferedReader; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.Socket; import java.net.UnknownHostException; import java.util.Scanner; public class Client extends Thread { Socket socket = null; public String result = ""; public String in = ""; public Client(String host, int port, String in) { try { in = new String(in.getBytes(),"GBK"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } this.in = in; try { socket = new Socket(host, port); socket.setSoTimeout(1000); } catch (UnknownHostException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } // public void shutDown() throws IOException { // if (socket != null) { // synchronized (socket) { // socket.close(); // } // } // System.out.println("StopClose.shutDown() complete"); // } @Override public void run() { new sendMessThread().start(); super.run(); try { InputStream s = socket.getInputStream(); byte[] buf = new byte[1024]; int len = 0; while ((len = s.read(buf)) != -1) { System.out.println(new String(buf, 0, len)); } } catch (IOException e) { e.printStackTrace(); } } class sendMessThread extends Thread{ @Override public void run() { super.run(); Scanner scanner=null; OutputStream os= null; try { scanner=new Scanner(System.in); os= socket.getOutputStream(); // String in; // do { // in=scanner.next(); // os.write((""+in).getBytes()); // os.flush(); // } while (!in.equals("bye")); for(int i =0;i<1;i++) { os.write((""+in).getBytes()); os.flush(); } BufferedReader rd = new BufferedReader(new InputStreamReader(socket.getInputStream(),"GBK")); String str = ""; System.out.println("RESULT AS FOLLOWING:"); while ((str = rd.readLine()) != null) { System.out.println(str); } // str = rd.readLine(); Client.this.result = str; System.out.println("Client.this.result:"+Client.this.result); rd.close(); } catch (IOException e) { e.printStackTrace(); } scanner.close(); try { os.close(); } catch (IOException e) { e.printStackTrace(); } } } public static void main(String[] args) { // Client clientTest=new Client("88.6.13.66", 13000); // Client clientTest=new Client("127.0.0.1", 1234,""); // clientTest.start(); } } ``` 这是调用的代码 ``` import java.io.BufferedReader; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.Socket; import java.net.UnknownHostException; import java.util.Scanner; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.sql.Connection; import java.sql.Types; import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; public class FaceCheckManage { private final static String DB_ALIAS = "ALIAS";//数据源 private static final String TRXZONE = "trxZone";//输入|地区号 private static final String TYPE = "type";//输入|操作类型 add-注册 check-识别 del-删除 private static final String IMG = "img";//输入|人脸数据 private static final String ID = "id";//输入|编号 private static final String VALUE = "VALUE";//输出|转发数据 public String process(IWFEngine engine, WFActivity activity, WFData wfd, String wfName) throws ParamNotExistException, com.zjft.bpe.stdlib.exception.UnrecognizedScopeException { BizDataModule dm = wfd.getDataModule(); ZjLogger logger = LoggerUtil.getLog(dm.getChannelId(), dm.getTxCode()); ModuleUtil moduleUtil = new ModuleUtil(wfd, wfd.getDataModule(), activity, logger); String trxZone = moduleUtil.getParamValue(TRXZONE); logger.debug("trxZone:"+trxZone); String type = moduleUtil.getParamValue(TYPE); String imgBase64 = moduleUtil.getParamValue(IMG); String id = moduleUtil.getParamValue(ID); Connection conn = wfd.getTxConnection(moduleUtil.getParamValue(DB_ALIAS)); try { /*是否已注册*/ boolean registedFlag = isRegisted(id, conn, logger); if("add".equals(type)&&registedFlag==true) { CommonUtil.setResponseMsg("FFFFF", "用户已注册,请先删除人脸数据", moduleUtil); return "fail"; }else if(("check".equals(type)||"del".equals(type))&&registedFlag==false) { CommonUtil.setResponseMsg("FFFFF", "用户人脸数据未注册", moduleUtil); return "fail"; } } catch (Exception e) { logger.error("查询是否已注册发生异常",e); CommonUtil.setResponseMsg("FFFFF", "查询是否已注册发生异常", moduleUtil); return "fail"; } JSONObject sysParams = null;//系统参数列表 try { //获取人脸识别配置参数 sysParams = getSysParam(type,conn, logger); }catch (TradeException e) { CommonUtil.setResponseMsg("FFFFF", e.getMessage(), moduleUtil); return "fail"; } catch (Exception e) { logger.error("查询人脸识别系统参数发生异常",e); CommonUtil.setResponseMsg("FFFFF", "查询人脸识别系统参数发生异常", moduleUtil); return "fail"; } String ip = sysParams.getString("ip"); String url =sysParams.getString("url"); //组参数 JSONObject paramMap = new JSONObject(); if("add".equals(type)) { paramMap.put("trxZone", trxZone); paramMap.put("programName", "e"); paramMap.put("id", id); paramMap.put("img1", imgBase64); paramMap.put("imgFace1", "50,60,100,120"); paramMap.put("hack1", 1); paramMap.put("customerAgreement", 1); String trxString = "10032"; String jsonString = paramMap.toJSONString(); int length = jsonString.length()+10; String lenString = getLenString(length); String totalString = trxString+lenString+jsonString; logger.debug("totalString:"+totalString); Client client = new Client("88.6.13.66", 13000,totalString); client.start(); String result = client.result; logger.debug("result:"+result); result = result.substring(5,result.length()); moduleUtil.setParamValue(VALUE, result); logger.debug("VALUE:"+result); JSONObject resultJsonObject = JSONObject.parseObject(result); logger.debug("resultJsonObject:"+resultJsonObject); //新增参数 }else if("check".equals(type)) { paramMap.put("trxZone", trxZone); paramMap.put("programName", "e"); paramMap.put("id", id); paramMap.put("img1", imgBase64); paramMap.put("imgFace1", "50,60,100,120"); paramMap.put("threshold", 0.001); paramMap.put("hack1", 1); String trxString = "10034"; String jsonString = paramMap.toJSONString(); int length = jsonString.length()+10; String lenString = getLenString(length); String totalString = trxString+lenString+jsonString; logger.debug("totalString:"+totalString); Client client = new Client("88.6.13.66", 13000,totalString); client.start(); String result = client.result; logger.debug("result:"+result); result = result.substring(5,result.length()); moduleUtil.setParamValue(VALUE, result); logger.debug("VALUE:"+result); JSONObject resultJsonObject = JSONObject.parseObject(result); logger.debug("resultJsonObject:"+resultJsonObject); }else if("del".equals(type)){ paramMap.put("trxZone", trxZone); paramMap.put("programName", "e"); paramMap.put("id", id); String trxString = "10035"; String jsonString = paramMap.toJSONString(); int length = jsonString.length()+10; String lenString = getLenString(length); String totalString = trxString+lenString+jsonString; logger.debug("totalString:"+totalString); try { totalString = new String(totalString.getBytes(),"GBK"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } Client client = new Client("88.6.13.66", 13000,totalString); client.start(); String result = client.result; logger.debug("result:"+result); result = result.substring(5,result.length()); moduleUtil.setParamValue(VALUE, result); logger.debug("VALUE:"+result); JSONObject resultJsonObject = JSONObject.parseObject(result); logger.debug("resultJsonObject:"+resultJsonObject); }else { CommonUtil.setResponseMsg("FFFFF", "错误的操作类型", moduleUtil); return "fail"; } String param = paramMap.toJSONString(); try { param = "params="+URLEncoder.encode(param,"UTF-8"); } catch (UnsupportedEncodingException e) { logger.error("转换为请求数据失败"); return "fail"; } return "ok"; } /** * <p> 函数名:isRegisted </p> * <p> 函数功能:查询该编号用户人脸信息是否已注册 </p> * <p> 处理过程:(描述这个方法的处理逻辑)</p> * <p> 输入参数描述: </p> * <p> 输出参数描述: </p> * <p> 异常处理描述: </p> * <p> 创建信息:liuyuan/2019年6月4日 下午3:29:48/versoin</p> * <p> 修改信息:(修改人名、修改人名.../最后修改时间/修改版本号)</p> * <p> 多个版本修改,则每次新增一行修改信息</p> * @throws Exception */ private boolean isRegisted(String id,Connection conn,ZjLogger logger) throws Exception { String sql = "select t.id from USER_FACE_RECORD t where t.id_number=? or t.user_no=?"; List<SQLPara> sqlParas = new ArrayList<>(); sqlParas.add(new SQLPara("id_number", Types.VARCHAR, id)); sqlParas.add(new SQLPara("user_no", Types.VARCHAR, id)); CachedRowSet rlt = DbOperate.executeQueryByParamName(sql, sqlParas, conn, logger); return rlt.next(); } /** * * <p>Title: getSysParam</p> * <p>Description: 查询人脸识别相关参数 </p> * @param type * @param conn * @param logger * @return * @throws TradeException * @throws Exception */ private JSONObject getSysParam(String type,Connection conn, ZjLogger logger) throws TradeException,Exception { JSONObject sysParam = new JSONObject(); String qrySysParamSQL = " select t.param_value from SYS_PARAM t where t.param_name=? "; List<SQLPara> sqlParas = new ArrayList<>(); // 查询ip sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_ip")); CachedRowSet ipRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!ipRlt.next()) { throw new TradeException("请先配置人脸识别服务器地址(faceCheck_ip)"); } sysParam.put("ip",ipRlt.getString("param_value")); sqlParas.clear(); // 查询url sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_url")); CachedRowSet urlRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!urlRlt.next()) { throw new TradeException("请先配置人脸识别转发url(faceCheck_url)"); } sysParam.put("url",urlRlt.getString("param_value")); sqlParas.clear(); // 查询baseFlag sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_baseFlag")); CachedRowSet baseFlagRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!baseFlagRlt.next()) { throw new TradeException("请先配置人脸识基准照标示(faceCheck_baseFlag)"); } sysParam.put("baseFlag",baseFlagRlt.getInt("param_value")); sqlParas.clear(); // 查询threshold sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_threshold")); CachedRowSet thresholdRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!thresholdRlt.next()) { throw new TradeException("请先配置人脸识误识率阈值(faceCheck_threshold)"); } sysParam.put("threshold",thresholdRlt.getString("param_value")); sqlParas.clear(); //查询channel sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_channel")); CachedRowSet channelRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!channelRlt.next()) { throw new TradeException("请先配置人脸识别转发业务渠道编号(faceCheck_channel)"); } sysParam.put("channel",channelRlt.getString("param_value")); sqlParas.clear(); //交易编号写死,加操作类型大写进行区分 sysParam.put("trCode","SXFH-BF-SWXJ-ITMS-FACE-"+type.toUpperCase()); //查询appName sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_appName")); CachedRowSet appNameRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!appNameRlt.next()) { throw new TradeException("请先配置人脸识别应用名(faceCheck_appName)"); } sysParam.put("appName",appNameRlt.getString("param_value")); sqlParas.clear(); //查询appInfo sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_appInfo")); CachedRowSet appInfoRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!appInfoRlt.next()) { throw new TradeException("请先配置人脸识别客户端APP信息(faceCheck_appInfo)"); } sysParam.put("appInfo",appInfoRlt.getString("param_value")); sqlParas.clear(); //查询retentionTime sqlParas.add(new SQLPara("param_name", Types.VARCHAR, "faceCheck_retentionTime")); CachedRowSet retentionTimeRlt = DbOperate.executeQueryByParamName(qrySysParamSQL, sqlParas, conn, logger); if (!retentionTimeRlt.next()) { throw new TradeException("请先配置人脸识清理时间(faceCheck_retentionTime)"); } sysParam.put("retentionTime",retentionTimeRlt.getString("param_value")); sqlParas.clear(); logger.debug("sysParam:"+sysParam); return sysParam; } public String getLenString (int length) { NumberFormat formatter = NumberFormat.getNumberInstance(); formatter.setMinimumIntegerDigits(5); formatter.setGroupingUsed(false); String lenString = formatter.format(length); return lenString; } } ``` 这个地方为什么总是空的 ![图片说明](https://img-ask.csdn.net/upload/201912/12/1576144606_651895.png)
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
有哪些让程序员受益终生的建议
从业五年多,辗转两个大厂,出过书,创过业,从技术小白成长为基层管理,联合几个业内大牛回答下这个问题,希望能帮到大家,记得帮我点赞哦。 敲黑板!!!读了这篇文章,你将知道如何才能进大厂,如何实现财务自由,如何在工作中游刃有余,这篇文章很长,但绝对是精品,记得帮我点赞哦!!!! 一腔肺腑之言,能看进去多少,就看你自己了!!! 目录: 在校生篇: 为什么要尽量进大厂? 如何选择语言及方...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
将代码部署服务器,每日早上定时获取到天气数据,并发送到邮箱。 也可以说是一个小型人工智障。 知识可以运用在不同地方,不一定非是天气预报。
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
英特尔不为人知的 B 面
从 PC 时代至今,众人只知在 CPU、GPU、XPU、制程、工艺等战场中,英特尔在与同行硬件芯片制造商们的竞争中杀出重围,且在不断的成长进化中,成为全球知名的半导体公司。殊不知,在「刚硬」的背后,英特尔「柔性」的软件早已经做到了全方位的支持与支撑,并持续发挥独特的生态价值,推动产业合作共赢。 而对于这一不知人知的 B 面,很多人将其称之为英特尔隐形的翅膀,虽低调,但是影响力却不容小觑。 那么,在...
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看...
白话阿里巴巴Java开发手册高级篇
不久前,阿里巴巴发布了《阿里巴巴Java开发手册》,总结了阿里巴巴内部实际项目开发过程中开发人员应该遵守的研发流程规范,这些流程规范在一定程度上能够保证最终的项目交付质量,通过在时间中总结模式,并推广给广大开发人员,来避免研发人员在实践中容易犯的错误,确保最终在大规模协作的项目中达成既定目标。 无独有偶,笔者去年在公司里负责升级和制定研发流程、设计模板、设计标准、代码标准等规范,并在实际工作中进行...
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
redis分布式锁,面试官请随便问,我都会
文章有点长并且绕,先来个图片缓冲下! 前言 现在的业务场景越来越复杂,使用的架构也就越来越复杂,分布式、高并发已经是业务要求的常态。像腾讯系的不少服务,还有CDN优化、异地多备份等处理。 说到分布式,就必然涉及到分布式锁的概念,如何保证不同机器不同线程的分布式锁同步呢? 实现要点 互斥性,同一时刻,智能有一个客户端持有锁。 防止死锁发生,如果持有锁的客户端崩溃没有主动释放锁,也要保证锁可以正常释...
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
Nginx 原理和架构
Nginx 是一个免费的,开源的,高性能的 HTTP 服务器和反向代理,以及 IMAP / POP3 代理服务器。Nginx 以其高性能,稳定性,丰富的功能,简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求,主要负责调度工作进程:加载配置、启动工作进程及非停升级。worker 进程负责处...
Python 编程开发 实用经验和技巧
Python是一门很灵活的语言,也有很多实用的方法,有时候实现一个功能可以用多种方法实现,我这里总结了一些常用的方法和技巧,包括小数保留指定位小数、判断变量的数据类型、类方法@classmethod、制表符中文对齐、遍历字典、datetime.timedelta的使用等,会持续更新......
YouTube排名第一的励志英文演讲《Dream(梦想)》
Idon’t know what that dream is that you have, I don't care how disappointing it might have been as you've been working toward that dream,but that dream that you’re holding in your mind, that it’s po...
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
Java世界最常用的工具类库
Apache Commons Apache Commons有很多子项目 Google Guava 参考博客
程序员把地府后台管理系统做出来了,还有3.0版本!12月7号最新消息:已在开发中有github地址
第一幕:缘起 听说阎王爷要做个生死簿后台管理系统,我们派去了一个程序员…… 996程序员做的梦: 第一场:团队招募 为了应对地府管理危机,阎王打算找“人”开发一套地府后台管理系统,于是就在地府总经办群中发了项目需求。 话说还是中国电信的信号好,地府都是满格,哈哈!!! 经常会有外行朋友问:看某网站做的不错,功能也简单,你帮忙做一下? 而这次,面对这样的需求,这个程序员...
相关热词 c# clr dll c# 如何orm c# 固定大小的字符数组 c#框架设计 c# 删除数据库 c# 中文文字 图片转 c# 成员属性 接口 c#如何将程序封装 16进制负数转换 c# c#练手项目
立即提问