求一个例子:java socket 采用ObjectInputStream序列化收发文件例子

求一个:java socket 采用ObjectInputStream序列化收发文件例子
求一个:java socket 采用ObjectInputStream序列化收发文件例子

4个回答

我参考 这个 例子 解决我的问题 http://bbs.csdn.net/topics/200033850

这不是我想要的 你给的这个例子类似的挺多的

楼上正解。就是Socket编程的基础知识,找个例子练习练习就熟悉了。
按你的要求,给个简单的对象序列号数据发送的例子,执行一遍就了能了解Socket的基本用法了。祝好。
SocketClient.java和SocketServer.java如下:

 import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.Date;

public class SocketClient {

    public void send(){
        InetSocketAddress address = new InetSocketAddress("localhost",8005);
        Socket socket = new Socket();
        try {
            socket.connect(address, 2000);

            ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
            Date date = new Date();
            out.writeObject(date);
            out.flush();
            System.out.println("Client send data finished.");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new SocketClient().send();
    }
}

import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class SocketServer {
    private ServerSocket serverSocket;

    public void receive(){
        while(true){
            try {
                serverSocket = new ServerSocket(8005);
                Socket socket = serverSocket.accept();
                ObjectInputStream in = new ObjectInputStream(socket.getInputStream());
                Object date = in.readObject();
                System.out.println("Server received data:"+date.toString());
                break;
            } catch (IOException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        new SocketServer().receive();
    }
}
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
请问大家见过这个异常吗java.io.StreamCorruptedException: invalid stream header: 7371007E异常求解

代码如下 ``` package Chat; import java.io.IOException; import java.io.ObjectInputStream; import java.net.Socket; public class ClientConServerThread extends Thread{ private Socket client; public ClientConServerThread(Socket client){ this.client=client; } public Socket getClient() { return client; } public void run(){ while(true){ try { ObjectInputStream ois = new ObjectInputStream(client.getInputStream());//这里出现了异常 Message m=(Message)ois.readObject(); System.out.println(m.getCon()); } catch (IOException | ClassNotFoundException e) { e.printStackTrace(); } } } } ``` 异常如下 java.io.StreamCorruptedException: invalid stream header: 7371007E at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 00007400 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 01417400 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 0C323031 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 39303033 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 30313134 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 3274001C at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 54756520 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 41707220 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 32382031 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 353A3436 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 3A313920 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 43535420 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 32303230 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 74000C32 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 30313930 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) java.io.StreamCorruptedException: invalid stream header: 30333031 at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:877) at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:350) at Chat.ClientConServerThread.run(ClientConServerThread.java:20) Process finished with exit code -1

java socket对象流输出时序列化的问题?

我现在需要服务端去查询数据库,得到一个Enumeration<>对象,然后该对象通过objetctOutputStream的对象传给客户端,为了序列化,我写了一个NetTransfer类。代码如下 ``` public class NetTransfer implements Serializable { Object obj; public Object getObj() { return obj; } public void setObj(Object obj) { this.obj = obj; } } ``` 服务端代码如下: ``` public static void getAllUser() { try { //服务器开始在数据库查询 Vector<User> userVec=new Vector<User>(); rSet=stmt.executeQuery("select * from userdata"); while(rSet.next()) { //以下只是我的程序中有不同类型的人,此处为多态 switch (rSet.getString("role")) { case "administrator": userVec.add(new Administrator(rSet.getString("name"), rSet.getString("password"), rSet.getString("role"))); break; case "operator": userVec.add(new Operator(rSet.getString("name"), rSet.getString("password"), rSet.getString("role"))); break; case "browser": userVec.add(new Browser(rSet.getString("name"), rSet.getString("password"), rSet.getString("role"))); break; default: break; } } Enumeration<User> e = userVec.elements(); NetTransfer allUsers=new NetTransfer(); allUsers.setObj(e); ObjectOutputStream oos=new ObjectOutputStream(client.getOutputStream()); /*异常提示此处没序列化*/ oos.writeObject(allUsers); oos.flush(); //oos.close(); }catch (Exception e) { e.printStackTrace(); } } ``` 客户端 ``` Enumeration<User> allUsers=null; //服务器返回的信息 ObjectInputStream ois=new ObjectInputStream(clientSocket.getInputStream()); NetTransfer allUsersTransfer=new NetTransfer(); allUsersTransfer=(NetTransfer)ois.readObject(); allUsers=(Enumeration<User>)allUsersTransfer.getObj(); //ois.close(); } catch (Exception e) { e.printStackTrace(); return allUsers; } return allUsers; } ``` 对序列化不是很懂,求助

java的ObjectInputStream的readObject

为何读出来的对象是null,代码: import java.io.*; import java.util.ArrayList; public class NewClass { public static void main(String[] args) throws ClassNotFoundException,IOException{ try(ObjectOutputStream output =new ObjectOutputStream(new FileOutputStream("didi.dat"));){ output.writeObject(new Student_2("林琅天","河南","17723526243","3220063463@qq.com",3)); } try(ObjectInputStream input =new ObjectInputStream(new FileInputStream("didi.dat"));){ Student_2 hh=(Student_2)(input.readObject()); System.out.println(hh.toString()); System.out.print(hh); } } } 结果是这样的:Student null null null null 3 Student null null null null 3成功构建 (总时间: 0 秒)

Java中的Socket编程关于多次输入输出的问题,希望给出解决方法

实现了多线程,这是服务端的代码:需求是接受客户端发送的数字,根据数字选择相应的case,当是1的时候要向服务端发送一个user的对象,ObjectInputStream ois=new ObjectInputStream(s.getInputStream());这句话的异常是java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2281), ``` public void run() { ObjectOutputStream oos=null; int choice=0; try { InputStream is=s.getInputStream(); choice=is.read(); System.out.println("接受成功"+choice); } catch (IOException e1) { e1.printStackTrace(); } switch (choice) { case 1: try { System.out.println("进入登录验证"); ObjectInputStream ois=new ObjectInputStream(s.getInputStream());_** /* ObjectInputStream ois=new ObjectInputStream(s.getInputStream());这句话的异常是java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2281),所以我就找到readFully(ObjectInputStream.java:2281)他的解释是 void readFully(byte[] b, int off, int len) throws IOException { int n = 0; while (n < len) { int count = read(b, off + n, len - n); if (count < 0) { throw new EOFException(); } n += count; } }_** */ Object obj=ois.readObject(); OutputStream os=s.getOutputStream(); if(obj instanceof User) { User user=(User)obj; String job=login(user); os.write(job.getBytes()); } os.close(); ois.close(); } catch (Exception e1) { e1.printStackTrace(); } ```

Caused by: java.lang.ClassNotFoundException: com.ibatis.common.jdbc.exception.NestedSQLException

``` 2019-12-23 10:31:58,907 ERROR [http-nio-8099-exec-120] action.PleasePayAction (SkyszLoggerLog4j.java:50) - 错误编号: (1577068318907) 请求URL:http://***url**/app/pleasePayAction/getAllAccount.html 异常信息:org.springframework.remoting.RemoteAccessException: Could not deserialize result from HTTP invoker remote service [http:/***url****/service/tssAccount.service]; nested exception is java.lang.ClassNotFoundException: com.ibatis.common.jdbc.exception.NestedSQLException at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.convertHttpInvokerAccessException(HttpInvokerClientInterceptor.java:212) at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:147) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) at com.sun.proxy.$Proxy72.getAcntUseableBal(Unknown Source) at com.skysz.app.pay.action.PleasePayAction.getAccInfo(PleasePayAction.java:1470) at com.skysz.app.pay.action.PleasePayAction.getAllAccount(PleasePayAction.java:1417) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) at javax.servlet.http.HttpServlet.service(HttpServlet.java:661) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at net.sf.ehcache.constructs.web.filter.GzipFilter.doFilter(GzipFilter.java:79) at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:93) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.skysz.framework.plugin.dhtmlx.grid.filter.PageHandlerRequestFilter.doFilter(PageHandlerRequestFilter.java:58) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.skysz.framework.filter.csrf.CSRFFilter.doFilter(CSRFFilter.java:92) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.skysz.framework.filter.sql.AntiSqlInjectionfilter.doFilter(AntiSqlInjectionfilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61) at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:167) at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:80) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at com.skysz.framework.filter.encoding.EncodingFilter.doFilter(EncodingFilter.java:36) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassNotFoundException: com.ibatis.common.jdbc.exception.NestedSQLException at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1309) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1137) at org.springframework.util.ClassUtils.forName(ClassUtils.java:250) at org.springframework.core.ConfigurableObjectInputStream.resolveClass(ConfigurableObjectInputStream.java:75) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1612) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1517) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990) at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:500) at java.lang.Throwable.readObject(Throwable.java:914) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1893) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1915) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1915) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370) at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.doReadRemoteInvocationResult(AbstractHttpInvokerRequestExecutor.java:292) at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.readRemoteInvocationResult(AbstractHttpInvokerRequestExecutor.java:243) at org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor.doExecuteRequest(SimpleHttpInvokerRequestExecutor.java:96) at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.executeRequest(AbstractHttpInvokerRequestExecutor.java:138) at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:194) at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:176) at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:144) ... 89 more ``` ``` ``` 有大神能看出来是什么问题吗 急!!!!感谢

抛SocketException: Socket is not connected

想些一个聊天软件 pc端服务器和客户端都写好了,但是再写安卓端时老是会出现 W/System.err: java.net.SocketException: Socket is not connected W/System.err: at java.net.Socket.getOutputStream(Socket.java:921) W/System.err: at server.MyMessage.send(MyMessage.java:66) W/System.err: at com.example.linqijun.qaclient.MainPageActivity$Destory.run(MainPageActivity.java:132) W/System.err: at java.lang.Thread.run(Thread.java:761) 我是将注册页面的socket传到mainui上用的,结果会出这个问题,网上也查不到,第一次提问,不符合规矩的地方还请大大们原谅。 代码如下 ``` public class LoginActivity extends AppCompatActivity { private EditText accountEdit; private EditText passwordEdit; private Button loginB; private Button registerB; private Handler handler = new Handler(){ @Override public void handleMessage(Message msg) { super.handleMessage(msg); Toast.makeText(LoginActivity.this,msg.obj.toString(),Toast.LENGTH_SHORT).show(); } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getSupportActionBar().hide(); setContentView(R.layout.activity_login); accountEdit = (EditText) findViewById(R.id.account); passwordEdit = (EditText) findViewById(R.id.password); registerB = (Button) findViewById(R.id.register); registerB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //启动注册 Intent intent = new Intent(LoginActivity.this,RegisterActivity.class); startActivity(intent); } }); loginB = (Button) findViewById(R.id.login); loginB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(accountEdit.getText().toString().equals("") || passwordEdit.getText().toString().equals("")){ Toast.makeText(LoginActivity.this,"can't be empty",Toast.LENGTH_SHORT).show(); return; } new Thread(new LoginThread()).start(); } }); } private class LoginThread implements Runnable{ private MySocket so; @Override public void run() { try { so = new MySocket("10.0.2.2",6870); double id = Double.parseDouble(accountEdit.getText().toString()); String password = passwordEdit.getText().toString(); User temp = new User(id,"0"); temp.setPassWord(password); MyMessage mgs = new MyMessage(temp); mgs.setType(1); mgs.send(so); DataInputStream dis = new DataInputStream(so.getInputStream()); ObjectInputStream ois = new ObjectInputStream(dis); MyMessage res = (MyMessage)ois.readObject(); if(res.getString().equals("success")){ //启动mainui activity User toNext = res.getUser(); Intent intent = new Intent(LoginActivity.this,MainPageActivity.class);//"extre data",toNext,so); Bundle bundle = new Bundle(); bundle.putSerializable("mgs",res); bundle.putSerializable("so",so); intent.putExtras(bundle); startActivity(intent); finish(); }else{ Message a = new Message(); a.obj = res.getString(); handler.sendMessage(a); } } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } while(true){ try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } } } ``` 然后是mainui的代码 ``` public class MainPageActivity extends AppCompatActivity { private MyMessage mgs; private User u; private MySocket so; private ImageButton userHead ; private TextView userName ; private ListView friends; private ArrayList<User> friendList ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getSupportActionBar().hide(); setContentView(R.layout.activity_main_page); Intent intent = getIntent(); mgs = (MyMessage) intent.getSerializableExtra("mgs"); so = (MySocket) intent.getSerializableExtra("so"); u = mgs.getUser(); friendList = u.getFriends(); //名字 String nameTemp = u.getName() + " ( "+ ((Double)u.getID()).toString() + " )"; userName = (TextView) findViewById(R.id.main_userName); userName.setText(nameTemp); //头像 userHead = (ImageButton)findViewById(R.id.main_head_photo); int photo = u.getPhotoType(); switch (photo){ case 0: userHead.setImageResource(R.drawable.f0); break; case 1: userHead.setImageResource(R.drawable.f1); break; case 2: userHead.setImageResource(R.drawable.f2); break; case 3: userHead.setImageResource(R.drawable.f3); break; case 4: userHead.setImageResource(R.drawable.f4); break; case 5: userHead.setImageResource(R.drawable.f5); break; case 6: userHead.setImageResource(R.drawable.f6); break; case 7: userHead.setImageResource(R.drawable.f7); break; case 8: userHead.setImageResource(R.drawable.f8); break; case 9: userHead.setImageResource(R.drawable.f9); break; case 10: userHead.setImageResource(R.drawable.f10); break; case 11: userHead.setImageResource(R.drawable.f11); break; } //好友列表 FriendAdapter adapter = new FriendAdapter(MainPageActivity.this,R.layout.friend_list,friendList); friends = (ListView)findViewById(R.id.main_friendList); friends.setAdapter(adapter); friends.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { User inTalk = friendList.get(position); } }); } @Override protected void onDestroy() { new Thread ( new Destory()).start(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } super.onDestroy(); } private class Destory implements Runnable{ @Override public void run() { MyMessage exitmsg = new MyMessage(u); exitmsg.setType(2); exitmsg.send(so); } } } ```

Java出现了java.io.StreamCorruptedException

java.io.StreamCorruptedException: invalid type code: 00 如题,我是在做模拟ATM的时候遇到问题 具体问题:java.io.StreamCorruptedException: invalid type code: 00 at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at programone.ATMMachine2.fileExist(ATMMachine2.java:36) at programone.ATMMachine2.main(ATMMachine2.java:60)

tomcat启动报java.io.EOFException,不影响运行

java.io.EOFException at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2577) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1315) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369) at net.bull.javamelody.CounterStorage.readFromFile(CounterStorage.java:110) at net.bull.javamelody.Counter.readFromFile(Counter.java:883) at net.bull.javamelody.Collector.<init>(Collector.java:111) at net.bull.javamelody.FilterContext.<init>(FilterContext.java:102) at net.bull.javamelody.MonitoringFilter.init(MonitoringFilter.java:111) at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:277) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4650) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5306) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722)

objectinputstream readobject 为何只能读取第一次写入的值

public class TransEntity implements Serializable//传输信息实体封装类 { private static final long serialVersionUID = 1L; private String operaType;//用户操作类型;如发送文本消息,发送语音消息,发送音频消息 private String responseTags;//网络响应状态;如“登录成功”、“登录失败”、“注册成功”、“注册失败” private String requestTags;//网络请求标记;请求发送文本消息,语音消息,音频消息 private User sender;//发送方; private User receiver;//接收方; private ArrayList<HashMap<String,Object>> buddylist;//好友列表信息; private String time;//系统时间; private ArrayList<HashMap<String,String>> inputGeneralMsgList;//通用信息 private HashMap<String,Object> outGeneralMsgMap; private String path; public String getUserOperaType() { return operaType; } public void setUserOperaType(String operaType) { this.operaType = operaType; } public String getResponseTags() { return responseTags; } public String setResponseTags(String responseTags) { return this.responseTags = responseTags; } public void setRequestTags(String requestTags) { this.requestTags = requestTags; } public String getRequestTags() { return requestTags; } public User getSender() { return sender; } public void setSender(User sender) { this.sender = sender; } public User getReceiver() { return receiver; } public void setReceiver(User receiver) { this.receiver = receiver; } public ArrayList<HashMap<String,Object>> getList() { return buddylist; } public void setList(ArrayList<HashMap<String,Object>> buddylist) { this.buddylist = buddylist; } public String getImagePath() { return path; } public void setImagePath(String path) { this.path = path; } public void setGeneralMessagefrom(ArrayList<HashMap<String,String>> inputGeneralMsgList) { this.inputGeneralMsgList = inputGeneralMsgList; } public ArrayList<HashMap<String,String>> getGeneralMessagefrom() { return inputGeneralMsgList; } public void setGeneralMessageto(HashMap<String,Object> outGeneralMsgMap) { this.outGeneralMsgMap = outGeneralMsgMap; } public HashMap<String,Object> getGeneralMessageto() { return outGeneralMsgMap; } public void setSysTime(String time) { this.time = SysTime.getDateTime(); } public String getSysTime() { return time; } } 服务端核心代码 public class ServerThread extends Thread { private static ObjectInputStream ois = null; private static ObjectOutputStream oos = null; private ArrayList<HashMap<String,Object>> list = null; private ArrayList<HashMap<String,String>> outgeneralMsgList = null; private Socket socket = null; private TransEntity trans = null; private boolean FLAGS_IsFirstLogin = true; private boolean FLAGS_LoginSucess = false; private boolean FLAGS_RegisterSucess = false; private boolean FLAGS_OnLine = false; private User user = null; private User receiver = null; private Timer timer = new Timer(); public ServerThread(Socket socket) { this.socket = socket; try { oos = new ObjectOutputStream(socket.getOutputStream()); ois = new ObjectInputStream(socket.getInputStream()); } catch (IOException e) { e.printStackTrace(); } } public void run() { try { while(true) { if(socket.isClosed() == false && socket.isConnected() == true) { try { if(ois!=null) { trans = (TransEntity) ois.readObject(); } } catch(java.net.SocketException e) { System.out.println("客户端已经关闭。。。。。。。"); break; } catch(ClassNotFoundException e) { System.out.println("--------空指针异常---------"); } catch(java.io.EOFException e) { System.out.println("客户端已经关闭。。。。。。。"); } } if(trans!=null) { user = trans.getSender(); receiver = trans.getReceiver(); if(trans.getUserOperaType()!=null) { System.out.println("----------trans.getUserOperaType() :------------"+(trans.getUserOperaType())); if(FLAGS_IsFirstLogin == true&&(UserOperaType.LOGIN.equals(trans.getUserOperaType()))) { //首次登录,一般情形下的客户端发过来的登录操作请求做处理,非掉线后的自动登录; System.out.println("--------server---socket :------"+(socket)); FLAGS_LoginSucess = setLogin(); } if(FLAGS_LoginSucess) { FLAGS_IsFirstLogin = false; System.out.println("----------trans.getUserOperaType() :------------"+(trans.getUserOperaType())); ......为何此次只能输出第一次读入的数据 if(UserOperaType.SEND_MESSAGE.equals(trans.getUserOperaType())) { System.out.println("-------UserOperaType.SEND_MESSAGE ---------"); System.out.println(trans.getGeneralMessageto().get("outMsg").toString()); if(trans.getGeneralMessageto()!=null)//若getGeneralMessageto()返回值不为空,则可以向数据库写入信息; { System.out.println("-------服务端:---发送方 写入普通信息到数据库,如文字消息;-----------"); SysCtlVar.dbBasicOperation.writeGeneralMessage(trans);// 发送方 写入普通信息到数据库,如文字消息; //trans.setGeneralMessageto(null); } trans.setUserOperaType(null); } oos.writeObject(trans); oos.flush(); } } } } } catch (Exception e) { e.printStackTrace(); } finally { } } } 客户端核心代码 while(SysCtlVar.FlAGS_LoginSuccess) { // System.out.println("--------------while SysCtlVar.FlAGS_LoginSuccess -------------"); try { try { SysCtlVar.trans = (TransEntity)SysCtlVar.ois.readObject(); if(SysCtlVar.inputGeneralMsgList!=null) synchronized(SysCtlVar.inputGeneralMsgList) { SysCtlVar.inputGeneralMsgList = SysCtlVar.trans.getGeneralMessagefrom(); SysCtlVar.inputGeneralMsgList.notify(); } synchronized(SysCtlVar.outGeneralMsgMap) { try { System.out.println("------- SysCtlVar.outGeneralMsgMap.wait----------"); SysCtlVar.outGeneralMsgMap.wait(); //等待直到有输入的时候,才把消息发送出去 System.out.println("---------------客户端: 正在发送消息。。。。。。------------------"); System.out.println("------- SysCtlVar.outGeneralMsgMap:----------"+(SysCtlVar.outGeneralMsgMap.get("outMsg").toString())); SysCtlVar.trans.setUserOperaType(UserOperaType.SEND_MESSAGE); SysCtlVar.trans.setGeneralMessageto(SysCtlVar.outGeneralMsgMap); System.out.println("------- SysCtlVar.trans.getGeneralMessageto():----------"+(SysCtlVar.trans.getGeneralMessageto().get("outMsg").toString())); try { SysCtlVar.oos.writeObject(SysCtlVar.trans); SysCtlVar.oos.flush(); } catch (IOException e) { e.printStackTrace(); } } catch (InterruptedException e) { e.printStackTrace(); } } } catch (ClassNotFoundException e) { e.printStackTrace(); } } catch (StreamCorruptedException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } } } 客户端 数据输入部分 /** 调试过程中,你将看到客户端输入的消息为h(第一条消息),www(第二条消息),a(第三条消息) 但是服务端只有第二条消息的值; */ //------------------发送消息 ---------- //客户端当前会话任务中,选中的消息接收者; new Thread() { public void run() { synchronized(SysCtlVar.outGeneralMsgMap) { System.out.println("------- 客户端:正在输入要发送的消息----------"); SysCtlVar.outGeneralMsgMap.clear(); SysCtlVar.outGeneralMsgMap.put("outMsg",outMsg); SysCtlVar.outGeneralMsgMap.put("msgRecver", selectedAccount); SysCtlVar.outGeneralMsgMap.put("dateTime",SysTime.getDateTime().toString()); SysCtlVar.outGeneralMsgMap.notify(); //输入完毕,通知发送任务执行 } } }.start(); 调试信息(服务器端) 服务器已启动,正在监听1345端口 ----------trans.getUserOperaType() :------------0 --------server---socket :------Socket[addr=/127.0.0.1,port=38516,localport=1345] ------- list!=null : ---------true [qq]上线了! ----------qq---------- ----------trans.getUserOperaType() :------------0 ----------trans.getUserOperaType() :------------6 ----------trans.getUserOperaType() :------------6 -------------UserOperaType.GET_AVATARS------------6 我想从服务器获取头像 ----------trans.getUserOperaType() :------------7 ----------trans.getUserOperaType() :------------7 -------UserOperaType.SEND_MESSAGE --------- www -------服务端:---发送方 写入普通信息到数据库,如文字消息;----------- insert into chat(sender,recver,message,sendtime) values('qq','在水一方','www','2015-04-24 16:15:13') ----------trans.getUserOperaType() :------------7 ----------trans.getUserOperaType() :------------7 -------UserOperaType.SEND_MESSAGE --------- www -------服务端:---发送方 写入普通信息到数据库,如文字消息;----------- insert into chat(sender,recver,message,sendtime) values('qq','在水一方','www','2015-04-24 16:15:13') ----------trans.getUserOperaType() :------------7 ----------trans.getUserOperaType() :------------7 -------UserOperaType.SEND_MESSAGE --------- www -------服务端:---发送方 写入普通信息到数据库,如文字消息;----------- insert into chat(sender,recver,message,sendtime) values('qq','在水一方','www','2015-04-24 16:15:13') ----------trans.getUserOperaType() :------------7 ----------trans.getUserOperaType() :------------7 -------UserOperaType.SEND_MESSAGE --------- www -------服务端:---发送方 写入普通信息到数据库,如文字消息;----------- insert into chat(sender,recver,message,sendtime) values('qq','在水一方','www','2015-04-24 16:15:13') ---------------问题补充--------------- 单步调试,客户端的输出流正确发送了每一次的客户端输入数据(36分钟前)删除 对于单步调试追踪的结果:客户端每一次发送的trans(它是TransEntity的实例,被序列化的消息实体对象)都是正确的(即,与客户端输入值相同)。但是服务端有ObjectInputStream读入的trans(它也是TransEntity的实例,被序列化的消息实体对象)却没有改变始终是第一次的值

java socket 传文件文件接收后不能打开

java socket传文件,客户端将文件读取到byte[]中,然后用Map对相关内容进行包装之后输出到服务器端,但服务器端读取文件内容的循环除第一次读取的Map是客户端写入过来的内容外,从第二次循环开始Map的内容都跟第一次一样的,请问怎么回事? 服务器端代码: `public void run() { ObjectInputStream is = null; OutputStream os = null; byte cache[] = new byte[1024]; Map map = null; int len = 0; String fileName = null; int i = 0; try { is = new ObjectInputStream(new BufferedInputStream(socket.getInputStream())); map = (Map)is.readObject(); fileName = "d:/" +(String)map.get("fn"); os = new BufferedOutputStream(new FileOutputStream(fileName)); //文件内容接收 while(true){ //map在第二次通过readObject方法读出后内容与第一次读取的值一样 map = (Map)is.readObject(); if(null==map){ continue; } if(((Boolean)map.get("fe"))){ break; } cache = (byte[])map.get("c"); if(null==cache || 0==cache.length){ continue; } len = (Integer)map.get("l"); os.write(cache,0,len); map = null; cache = null; } os.flush(); System.out.println("--->over"); } catch (IOException e) { e.printStackTrace(); }catch (Exception e){ e.printStackTrace(); }finally { try{ if(null!=is){ is.close(); is = null; } if(null!=os){ os.close(); os = null; } if(null!=socket){ socket.close(); socket = null; } }catch (Exception e){ e.printStackTrace(); } } } 客户端代码: `public void actionPerformed(ActionEvent e) { Map map = null; Socket socket = null; ObjectOutputStream oos = null; InputStream is = null; byte cache[] = new byte[1024]; int len = 0; try { socket = new Socket("192.168.88.154",8888); socket.setSoTimeout(10*1000); socket.setKeepAlive(true); File file = new File(jTextField.getText()); is = new BufferedInputStream(new FileInputStream(file)); oos = new ObjectOutputStream(new BufferedOutputStream(socket.getOutputStream())); //文件名称 map = new HashMap(); map.put("fn",file.getName()); map.put("fl",file.length()); map.put("fe",false); oos.writeObject(map); oos.flush(); //文件内容 while(true){ map.clear(); if((len=is.read(cache))<=0){ break; } map.put("c",cache); map.put("l", len); map.put("fe", false); oos.writeObject(map); } oos.flush(); //文件结束 map = new HashMap(); map.put("fe",true); oos.writeObject(map); oos.flush(); } catch (IOException e1) { e1.printStackTrace(); } finally { try{ if(null!=is){ is.close(); is = null; } if(null!=oos){ oos.close(); oos = null; } if(null!=socket){ socket.close(); socket = null; } }catch (Exception e1){ e1.printStackTrace(); } } }

Java对象流读取时出错

import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.OutputStream; import java.io.Serializable; import java.net.ServerSocket; import java.net.Socket; public class sever { public static void main(String[] args) throws ClassNotFoundException { Socket socket; InputStream is; ObjectInputStream ois; FileOutputStream fos; File file; Object object; User user=null; try { ServerSocket ss=new ServerSocket(9999); socket=ss.accept();System.out.print("hh"); is=socket.getInputStream(); ois=new ObjectInputStream(is); user=(User)ois.readObject(); 这一行有错误。 file=new File("C:/Users/lenovo/Desktop/gg1/a.mp4"); fos=new FileOutputStream(file); while(true){ fos.write(user.getBytes(), 0,user.getBytes().length); fos.flush(); } } catch (IOException e) { } } } class User implements Serializable{ private static final long serialVersionUID = 1L; private byte[] bytes=new byte[1024]; public byte[] getBytes() { return bytes; } public void setBytes(byte[] bytes) { this.bytes = bytes; } } 这个是服务器端,在从对象流中读取对象的时候报错了(错误的地方上面有标识) 错误提示: java.lang.ClassNotFoundException 请求路过的各位大神解答一下

Android应用socket创建失败,抛出IOException,大神帮忙看看因为什么

上代码: 服务器端 ``` package com.boge.server.model; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; import java.util.Date; import com.boge.mq.common.User; import com.boge.mq.common.YQMessage; import com.boge.mq.common.YQMessageType; public class MQServer { ServerSocket mServerSocket = null; Socket mSocket = null; ObjectInputStream oic = null; ObjectOutputStream oos = null; public MQServer() { try { mServerSocket = new ServerSocket(30000); System.out.println("MQ服务器已启动 in " + new Date()); while (true) { mSocket = mServerSocket.accept(); oic = new ObjectInputStream(mSocket.getInputStream()); oic.close(); oos.close(); mSocket.close(); } } catch (IOException e) { e.printStackTrace(); } } } ``` Android应用界面: ``` package com.boge.mq.client.view; import com.boge.mq.R; import com.boge.mq.common.User; import com.goge.mq.client.model.ClientConServerThread; import com.goge.mq.client.model.MQClient; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.view.View; import android.view.View.OnClickListener; import android.view.Window; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class LoginActivity extends Activity { Context mContext = null; EditText et_account, et_password; public Handler handler; public User user=null; public ClientConServerThread clientThread; @Override protected void onCreate(Bundle savedInstanceState) { mContext = this; super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_login); et_account = (EditText) findViewById(R.id.et_account); et_password = (EditText) findViewById(R.id.et_password); handler = new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == 0x123) { Intent intent = new Intent(mContext, MainActivity.class); startActivity(intent); } } }; Button btn_login = (Button) findViewById(R.id.btn_login); btn_login.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { login(123, "123"); } }); } public void login(int a, String p) { user=new User(); user.setAccount(a); user.setPassword(p); clientThread=new ClientConServerThread(handler,user); clientThread.start(); } } ``` socket线程 ``` package com.goge.mq.client.model; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketTimeoutException; import android.os.Handler; import android.os.Message; import com.boge.mq.common.User; import com.boge.mq.common.YQMessage; public class ClientConServerThread extends Thread { Socket socket = null; ObjectOutputStream osStream = null; ObjectInputStream inStream = null; User user; YQMessage mess = null; Handler handler; public Handler revHandler; public ClientConServerThread(Handler h, User u) { user = u; handler = h; } @Override public void run() { try { socket = new Socket(); try { socket.connect(new InetSocketAddress("192.168.1.140", 30000), 2000); } catch (SocketTimeoutException e) { e.printStackTrace(); } osStream = new ObjectOutputStream(socket.getOutputStream()); inStream = new ObjectInputStream(socket.getInputStream()); Message msg = new Message(); msg.what = 0x123; handler.sendMessage(msg); socket.close(); osStream.close(); inStream.close(); } catch (IOException e) { e.printStackTrace(); } } } ``` 我已确定,就是在厦门这句除了问题,抛出IO异常 ``` try { socket.connect(new InetSocketAddress("192.168.1.140", 30000), 2000); } ``` 求大神解答

java 客户端往服务器端传递一个对象时,总是卡死,求解答。

java 客户端往服务器端用ObjectOutputStream的writeObject()传递一个对象时,总是卡死。 java.net.BindException: Address already in use: JVM_Bind java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: sun.applet.AppletAudioClip at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1355) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2000) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1924) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2000) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1924) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371) at GoBangGame.GoBangServer$HandleGoBang.receiveMoveFromPlayer(GoBangServer.java:289) at GoBangGame.GoBangServer$HandleGoBang.run(GoBangServer.java:99) at java.lang.Thread.run(Thread.java:745) Caused by: java.io.NotSerializableException: sun.applet.AppletAudioClip at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348) at GoBangGame.GoBangClient.sendMoveToServer(GoBangClient.java:129) at GoBangGame.GoBangClient.run(GoBangClient.java:104) ... 1 more

socket通信 客户端报错

java.net.SocketException: Connection reset 服务端 public static void main(String[] args) { ConfigManager man=ConfigManager.getInstance(); List<CommandGroup> group=man.getCommandGroup(); List<Socket> socket=null; try { ServerSocket server=new ServerSocket(9123); socket=new ArrayList<Socket>(); while (true) { server.setSoTimeout(5000); Socket sockcet= server.accept(); socket.add(sockcet); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } for (int i = 0; i < socket.size(); i++) { byte[] buf=OtherUtils.toSerialize(group.get(0)); PackageFactory.write(buf, socket.get(i)); } } ``` ``` 客户端 ``` public static void main(String[] args) { try { Socket socket=new Socket("localhost", 9123); System.out.println(socket.isClosed()); ObjectInputStream inputStream = new ObjectInputStream(new BufferedInputStream(socket.getInputStream())); CommandGroup group =(CommandGroup) inputStream.readObject(); System.out.println(group.getLoop()); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } ``` 报错:![图片说明](https://img-ask.csdn.net/upload/201511/23/1448261510_934131.png)

JAVA中ObjectInputStream中将多个Object存入ArrayList中

ArrayList用迭代器存进文件的数据怎么取回到ArrayList中 循环判定是什么 我写了一个总是报 EOF异常

JAVA突然碰到个问题,objectinputstream对象咋读到结束啊

available()!=0不行啊,貌似头验证什么的会阻塞,一开始就会 然后就是readObject()!=null来判断,这个貌似也不行啊,看了下源码,读到文件结束了再调用 这个方法会抛出EOFException 这是我在追加对象序列化反序列化的时候碰到的,有没有大手子给我解决下

使用socket通信,android客户端,java写的服务器,传输数据时总出现异常

客户端: public void run() { // TODO Auto-generated method stub try { s = new Socket(ip, port); DataOutputStream os = new DataOutputStream(s.getOutputStream()); os.writeUTF("可以准备接收了吗?"); ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream()); out.writeObject(u); out.flush(); out.close(); System.out.println("用户名是:"+u.getID()); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } ``` ``` 服务器: ``` try{ ServerSocket ss = new ServerSocket(9999); System.out.println("服务器正在监听!"); Socket s = ss.accept(); System.out.println("建立连接!"); DataInputStream is = new DataInputStream(s.getInputStream()); String str = is.readUTF(); System.out.println(str); ObjectInputStream ois = new ObjectInputStream(s.getInputStream()); User u = (User)ois.readObject(); ois.close(); System.out.println("用户ID :"+u.getID()); }catch(Exception e){ e.printStackTrace(); } ``` 异常: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at java.io.DataInputStream.readUnsignedShort(Unknown Source) at java.io.DataInputStream.readUTF(Unknown Source) at java.io.DataInputStream.readUTF(Unknown Source) at com.server.EasyServer.main(EasyServer.java:24) (在os.writeUTF一行)

JAVA中在使用Socket从客户端项服务端传文件时,程序阻塞在获取Socket套接字输入流那一行是为什么?

这样写会阻塞在下面那一行,而调整位置后成功时什么问题,在我的理解中这一行的声明只要出现在使用之前就可以了。望解答,感谢 客户端上传文件程序 ``` Socket socket = new Socket("127.0.0.1", 8888); File file = new File("D:\\1610\\android素材\\bg04.jpg"); BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream()); **ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());** //阻塞在这一行?我把这一行放在下面时该程序就运行成功,这之间有什么关系吗?希望大神解答,感谢!!!! System.out.println(file.getName()); oos.writeUTF(file.getName()); oos.writeLong(file.length()); byte[] arr = new byte[1024]; int len; while((len = bis.read(arr)) != -1){ oos.write(arr,0,len); oos.flush(); } // 上面那一行放在该位置 System.out.println("1111"); if(ois.readUTF().equals("下载成功")){ System.out.println("文件上传成功"); ois.close(); oos.close(); bis.close(); socket.close(); } ``` 服务端接受文件代码块 ``` ServerSocket serverSocket = new ServerSocket(8888); System.out.println("服务器已启动..."); while (true) { Socket socket = serverSocket.accept(); ObjectInputStream ois = new ObjectInputStream(socket.getInputStream()); //这个位置 String fileName=ois.readUTF(); long extent = ois.readLong(); System.out.println(extent); File file = new File("D:/TestFile"); if (file.isDirectory()) { System.out.println("文件夹已存在"); } else { file.mkdirs(); } BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file.getAbsolutePath() +"/"+ fileName)); BufferedWriter bw = new BufferedWriter(new FileWriter("down.log",true)); _**ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());**_//或者是我把这一行放在上面位置也能成功 byte[] arr = new byte[1024]; int len; long total = 0; while ((len = ois.read(arr)) != -1) { bos.write(arr, 0, len); total += len; bw.write("当前已下载" + (total * 100) / extent + "%" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); bw.newLine(); bw.flush(); if (total == extent) { oos.writeUTF("下载成功"); break; } } System.out.println("下载成功"); oos.close(); bw.close(); bos.close(); ois.close(); socket.close(); } ```

请求大佬支援!!!报错java.io.NotSerializableException

![图片说明](https://img-ask.csdn.net/upload/201911/27/1574838012_281817.jpg) ``` package com.bjsxt.singleton; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; public class Client2 implements Serializable{ private static final long serialVersionUID = 1L; public static void main(String[] args) throws Exception { SingletonDemo6 s1 = SingletonDemo6.getInstance(); SingletonDemo6 s2 = SingletonDemo6.getInstance(); System.out.println(s1); System.out.println(s2); //通过反序列化的方式构造多个对象 FileOutputStream fos = new FileOutputStream("d:/a.txt"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(s1);//序列化 oos.close(); fos.close(); ObjectInputStream ois = new ObjectInputStream(new FileInputStream("d:/a.txt")); SingletonDemo6 s3 = (SingletonDemo6) ois.readObject(); System.out.println(s3); ois.close(); } } ```

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

为什么本科以上学历的人只占中国人口的5%,但感觉遍地都是大学生?

中国大学生占总人口不到5% 2017年,中国整体的本科率仅有5.9%;如果算上研究生,这一比例可以进一步上升到6.5% 为什么在国家统计局推出的这份年鉴中,学历的最高一阶就是到研究生,而没有进一步再统计博士生的数量的。 原因其实并不难理解,相比全国和各省整体人口体量,博士生的占比非常之低,属于绝对意义上的小概率样本。 这一点,我们从上表中的各省研究生占比情况也可以看出端倪。除北京、天津、上海三...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

程序员写出这样的代码,能不挨骂吗?

当你换槽填坑时,面对一个新的环境。能够快速熟练,上手实现业务需求是关键。但是,哪些因素会影响你快速上手呢?是原有代码写的不够好?还是注释写的不够好?昨夜...

外包程序员的幸福生活

今天给你们讲述一个外包程序员的幸福生活。男主是Z哥,不是在外包公司上班的那种,是一名自由职业者,接外包项目自己干。接下来讲的都是真人真事。 先给大家介绍一下男主,Z哥,老程序员,是我十多年前的老同事,技术大牛,当过CTO,也创过业。因为我俩都爱好喝酒、踢球,再加上住的距离不算远,所以一直也断断续续的联系着,我对Z哥的状况也有大概了解。 Z哥几年前创业失败,后来他开始干起了外包,利用自己的技术能...

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

记录下入职中软一个月(外包华为)

我在年前从上一家公司离职,没想到过年期间疫情爆发,我也被困在家里,在家呆着的日子让人很焦躁,于是我疯狂的投简历,看面试题,希望可以进大公司去看看。 我也有幸面试了我觉得还挺大的公司的(虽然不是bat之类的大厂,但是作为一名二本计算机专业刚毕业的大学生bat那些大厂我连投简历的勇气都没有),最后选择了中软,我知道这是一家外包公司,待遇各方面甚至不如我的上一家公司,但是对我而言这可是外包华为,能...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

6年开发经验女程序员,面试京东Java岗要求薪资28K

写在开头: 上周面试了一位女程序员,上午10::30来我们部门面试,2B哥接待了她.来看看她的简历: 个人简历 个人技能: ● 熟悉spring mvc 、spring、mybatis 等框架 ● 熟悉 redis 、rocketmq、dubbo、zookeeper、netty 、nginx、tomcat、mysql。 ● 阅读过juc 中的线程池、锁的源...

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

都前后端分离了,咱就别做页面跳转了!统统 JSON 交互

文章目录1. 无状态登录1.1 什么是有状态1.2 什么是无状态1.3 如何实现无状态1.4 各自优缺点2. 登录交互2.1 前后端分离的数据交互2.2 登录成功2.3 登录失败3. 未认证处理方案4. 注销登录 这是本系列的第四篇,有小伙伴找不到之前文章,松哥给大家列一个索引出来: 挖一个大坑,Spring Security 开搞! 松哥手把手带你入门 Spring Security,别再问密...

立即提问
相关内容推荐