2013年12月19日星期四

json garbled


List list = new ArrayList();   
list.add("张三");   
list.add("李四");   
JSONArray jsonArray = JSONArray.fromObject(list);   
System.out.println(jsonArray);   
String xmltest=new XMLSerializer().write(jsonArray);   
System.out.println(xmltest);  


------- --------- first print properly
[" Joe Smith ", " John Doe " ]

------- second print garbled ---------

Laos Jizhu Li Yiqi < / a>

------ Solution ------------------------------------ --------
try to write (json, "GBK");
------ For reference only ----------- ----------------------------
your XML encoding problem ...
------ For reference only ---------------------------------------
you call that generates xml the beginning is how the declared ? utf-8? Or GBK? Oh, to be a unified coding .
------ For reference only -------------------------------------- -
agree 3rd floor
------ For reference only ------------------------------- --------



positive solutions
------ For reference only --------------------------------- ------
write (json, "GBK");
been tried, useless , garbled or identical
Another

XMLSerializer not write my own class ah, yes
------ For reference only net.sf.json.xml.XMLSerializer under ----------- ----------------------------
above mistake

write (json, "GBK");

this does not garbled

but I have not mentioned before a request, I asked xml must be
------ For reference only utf-8 of -------------- -------------------------
foreground and background has been encoded . . .
------ For reference only -------------------------------------- -

noon windows console default encoding is gbk, UTF-8 strings had to chaos.
------ For reference only -------------------------------------- -
either transcoding , or Unicode . Only select one
------ For reference only ---------------------------------- -----
your eclipse utf-8 encoding change to the next would not be garbled

look at project properties encoding is not utf-8 to write your business methods

Project - > Properties -> resource -> utf-8 encoding election platform of choice for the appropriate operating system
--- --- For reference only ---------------------------------------

Drop-down list values ??from a database problem ~ ~

Want the transfer of data from the database into the drop-down list , below is the code. But always fail to get value .
Great God seeking to explain ~ ~


<select id="example" name="example">
<option value="请选择" selected="selected">请选择</option>
    <%ResultSet rs1=null;
    String str1="select distinct exdate from note";
    Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con1 = DriverManager.getConnection("jdbc:oracle:thin:@132.232.36.137:1521:manage", "server","server");
Statement stmt1 = con1.createStatement();
rs1= stmt1.executeQuery(str1);
%>
<%while(rs1.next())
     {%>
     <option value="<%=rs1.getString("EXDATE") %>" ></option>
<%}
%>
</select></td>   

------ Solution ------------------------------------- -------
alas, the boss then you end affixed to the I dotted it
------ For reference only --------------- ------------------------
found the problem. . . was written

java how to write the menu on the left tree

action in the transfer of the code below:
public String listValueStandard(){
System.out.println("listValueStandard");
List<ValueStandard> types=basicNormService.getAllValueStandard();
List<TreeJson> trees = new ArrayList<TreeJson>();
for(int i=0;i<types.size();i++){
TreeJson json = new TreeJson();
json.setId(types.get(i).getValueStandardId()+"");
System.out.println("pid"+types.get(i).getParentId());
if(types.get(i).getParentId()==null){
json.setPid(null);
}else{
json.setPid(types.get(i).getParentId()+"");
}
json.setText(types.get(i).getName());
trees.add(json);
}
List<TreeJson> jsons = ListToTree.formatTree(trees);
JSONArray jsonarray=JSONArray.fromObject(types);
listValueStandard=jsonarray.toString();
return "tovaluestandard";
}


write unable retrieval success , the following is called the tree

entity classes :
 

public class ValueStandard implements java.io.Serializable {

// Fields

private Integer valueStandardId;
private Integer parentId;
private String name;
private String note;
private String sequence;

// Constructors

/** default constructor */
public ValueStandard() {
}

/** minimal constructor */
public ValueStandard(Integer parentId) {
this.parentId = parentId;
}

/** full constructor */
public ValueStandard(Integer parentId, String name, String note,
String sequence) {
this.parentId = parentId;
this.name = name;
this.note = note;
this.sequence = sequence;
}

// Property accessors

public Integer getValueStandardId() {
return this.valueStandardId;
}

public void setValueStandardId(Integer valueStandardId) {
this.valueStandardId = valueStandardId;
}

public Integer getParentId() {
return this.parentId;
}

public void setParentId(Integer parentId) {
this.parentId = parentId;
}

public String getName() {
return this.name;
}

public void setName(String name) {
this.name = name;
}

public String getNote() {
return this.note;
}

public void setNote(String note) {
this.note = note;
}

public String getSequence() {
return this.sequence;
}

public void setSequence(String sequence) {
this.sequence = sequence;
}

}

------ Solution ------------------------------------- -------
java tree menu on the left to do http://blog.sina.com.cn/s/blog_6c7f922d0100q9xo.html
------ Solution ---------------------------------------- ----
do it in the page , with the z-tree, well used
------ Solution ------------------- -------------------------
tree menu can be done is ugly
------ Solution ----- ---------------------------------------
a look at how to achieve a recursive algorithm , imitate what you can . This simple recursive menu easier to achieve
------ Solution ------------------------------- -------------
entity class encapsulates error
------ Solution -------------------- ------------------------
feel easyUI foreground framework written in this more convenient
------ Solution ---- ----------------------------------------
http://blog.csdn .net/yeness/article/details/9496647
------ Solution ------------------------------ --------------
after setting up the data sets in the foreground show , this is a graphic design in general , and their own words to the Internet to look for your favorite style , but also a lot of
------ Solution ---------------------------------------- ----

I 've written a tree , and now mainly to the transfer of this tree , as an attribute of another one table.  


Oh misunderstood you mean, you want to call is now showing a tree in another page? If so you can use ajax call to this method alone extracted directly return a json string or data can be of
------ Solution --------------- -----------------------------
http://www.ztree.me/v3/demo.php
------ For reference only ---------- -----------------------------
their top .
------ For reference only -------------------------------------- -

Well using easyUI reception
------ For reference only ---------------------- -----------------

I 've written a tree , and now mainly to the transfer of this tree , as an attribute of another one table.
------ For reference only -------------------------------------- -

I 've written a tree , and now mainly to the transfer of this tree , as an attribute of another one table. Write
how to modify the above action
------ For reference only --------------------------- ------------

I 've written a tree , and now mainly to the transfer of this tree , as an attribute of another one table.          
  
  
Oh misunderstood you mean, you want to call is now showing a tree in another page? If so you can use ajax call to this method alone extracted directly return a json string or the data can be  
Well I use ajax, but backstage action retrieval tree method is not so, the above is the transfer of a tree way I write, but can not be adjusted to take, you help me look at the code , where there are problems.
------ For reference only -------------------------------------- -
been resolved , thank you.

Great God help us to see them , as long as the page is opened , it is displayed twice that table



















Can not find or load main class

I'm furious ! java beginner, engage in the afternoon today , there are two problems:
.
1 compile time , a direct hit in the dos window javac Test.java prompt " File not found" , so I added a path in front : "c: \ Users \ 1 \ desktop \ Test.java " just fine , gave birth to the class file , though passed, but still have a problem , why others can not trails?
After
2. generate class files , enter "java Test" Enter a " Can not find or load main class " in the dos window, I found a lot of solutions will not work.

environment variables:

Classpath:;.% Java_Home% \ lib

Java_Home: D: \ Program Files \ Java \ jdk1.7.0_11

Path:% Java_Home% \ bin

code is as follows :

public class Test

{

public static void main (String [] args)

{

System.out.println ("Hello World!");

}

}
these two problems are not related ah ?
------ Solution ---------------------------------------- ----
your working directory in the desktop cmd in what
------ For reference only ---------------------- -----------------
great God please help me , Online!
------ For reference only -------------------------------------- -
java installed on it?
Open dos:
java-version

take a look at what the output
------ For reference only ----------------------------- ----------
certainly fitted the way, is the 1.6 version , I just found a problem that only in the root directory of each disk in order to compile and run successfully. For example, I built on the D drive a Test.java, dos window and then type D: Enter, then type javac Test.java ( no need to enter the path ) , compiled successfully , enter java Test return, run success. How is this going ?
------ For reference only -------------------------------------- -
Yes, ah , no, , dos default is c: \ users \ 1 below
------ For reference only --------------- ------------------------


your files in c: \ users \ 1 \ desktop you are in c: \ users \ 1 how might find it?

When you hit java Test he will not help you scan your hard disk to find Test.class ah
------ For reference only ---------------- -----------------------


You look at my reply to the third floor , is not only to build java files in the root directory ah
------ For reference only ---------------- -----------------------


not

Because you do when your working directory is D: \ where your files are

If you want to place the file in c: \ users \ 1 \ desktop, when you first thing to do is punch cmd
cd desktop

then javac Test.java
java Test
------ For reference only ------------------------------- --------
that if I usually put the program files on the E drive a folder under the n how do
------ For reference only ------ ---------------------------------


For example, the file in your E: \ toto \ titi \ Test.java

either after you hit cmd
e:
cd toto \ titi
javac Test.java
java Test After you hit cmd either

javac E: \ toto \ titi \ Test.java
java E: \ toto \ titi \ Test
------ For reference only ------------------------ ---------------
  The reply was deleted administrator at 2013-01-18 08:58:02

------ For reference only ---------------------------------- -----
Thank you very much !
------ For reference only -------------------------------------- -
this run java program also appeared "Unable to load the main class " error , close the DOS window , then enter the program directory , run no such mistake , very strange , oh !
------ For reference only -------------------------------------- -
I know why
Right-click the project properties-java Builder Path-Libraries see your jdk right

Java beauty series Bowen - welcome to vote for me !

first to welcome everyone to vote for me : (2013CSDN blog Star Award )
http://vote.blog.csdn.net/blogstaritem/blogstar2013/zhangerqing
some knowledge of my own summary
Java -based aspects , as a Java programmer , we need to put them all to learn through, this is just a part of every so often there will be a new blog post came out, welcome everyone to read !

Java beauty [ evolution from novice to expert ] of string processing

Java beauty [ evolution from novice to expert ] 's collections

Java beauty [ evolution from novice to expert ] of HashMap, HashTable

Java beauty [ evolution from novice to expert ] The JVM memory management and garbage collection

Java beauty [ evolution from novice to expert ] design pattern

Java beauty [ evolution from novice to expert ] design model two

Java beauty [ evolution from novice to expert ] three design patterns

Java beauty [ evolution from novice to expert ] Four design patterns

Java beauty [ evolution from novice to expert ] of Exception

Java beauty [ evolution from novice to expert ] of XML parsing and packaging

Java beauty [ From novice to expert evolution ] of classes and objects ( a ) ;

Java beauty [ evolution from novice to expert ] of classes and objects ( two ) ;

Java beauty [ From novice to expert evolution ] of classes and objects ( three )

Java beauty [ evolution from novice to expert ] as much thread profile

Java beauty [ evolution from novice to expert ] of thread synchronization introduced < br> ------ Solution ----------------------------------------- ---
landlord must post the 12-year -fat knot it, and before this post seems almost content .

give you a vote , and I have to vote for it

http://vote.blog.csdn.net/blogstaritem/blogstar2013/huxiweng
------ Solution ---------------------------------------- ----
voting support what
------ Solution ---------------------------------- ----------
has cast
------ Solution ------------------------------------ --------
voted , 11 tickets
------ Solution - -------------------------------------------
12 vote,
------ Solution - -------------------------------------------

------ Solution ----- ---------------------------------------
cast , huh, huh .
------ Solution ---------------------------------------- ----
section 7 , and refueling
------ Solution - -------------------------------------------
System.out. println ((2.0-1.1) == 0.9);

Why?
------ Solution -------------------------------------- ------
voted oh.
------ Solution - -------------------------------------------
voted ah. . .
------ Solution ---------------------------------------- ----

12 years have been found not post knot ah. . . . . .
------ For reference only -------------------------------------- -
give you voted , post knot soon !
------ For reference only -------------------------------------- -
thanks Ha !
------ For reference only -------------------------------------- -
Thank you !
------ For reference only ---------------------------------------

------ For reference only ------ ---------------------------------
   Shen gone then !
------ For reference only -------------------------------------- -
to a statement posted on the 20th floor , grasp ah !
------ For reference only -------------------------------------- -

---- - For reference only ---------------------------------------

12 years have been found not post knot ah. . . . . .   Oh , just forget it, already have got . Welcome to vote for me , immediately got this post .
http://vote.blog.csdn.net/blogstaritem/blogstar2013/zhangerqing
------ For reference only -------------------------------------- -
refueling

I made a website and findjar.com almost, we look at where you need to improve

As the title of my website www.findmaven.net and www.find.com the biggest difference can be found in the fuzzy according to class or jar jar maven repository name in the link (GAV group: artifact: version).
you have any good ideas do better or improve opinion? Give me some suggestions to make this site better and stronger .


------ Solution ------------------------------------ --------
good landlord refueling
------ For reference only ----------------------- ----------------
page elements feel a little

hibernate annotations one how to write

There are two tables A B
Table A fields:
id name bid ( foreign key )
Table B fields:
id name

entity class

@Eneity
public class A {

  @Id
  @GeneratedValue
  private int id;
  private Sreing name;
  
  @OneToOne       //这里该怎么写
  private int bid;

  //setter  getter......
}

@Eneity
public class B {

  @Id
  @GeneratedValue      //这里要写什么?
  private int id;
  private Sreing name;

  //setter  getter......
}


hql how to write in order to make final
select * from A
Return to the list so there
B 's name
------ Solution -------------------- ------------------------ entity class a landlord 's wrong


@ Eneity
public class A {

@ Id
@ GeneratedValue
private int id;
private Sreing name;

@ OneToOne / / Here how to write
private B b;

/ / setter getter ......
}
.
so check out the A, B 's name had a list.get (i) getB () getName ();.
------ Solution ----- ---------------------------------------
hibernate recommend using bidirectional many- to achieve one
------ Solution ------------------------------------ --------


@Entity
public class A {
//最好还是把这些注解写在getter上
  @Id
  @GeneratedValue
  private int id;
  private String name;
  private int bid;
  @OneToOne
  @JoinColumn(name="bid",insertable=false,updatable=false)
  private B b;

  //setter  getter......
}

@Eneity
public class B {
//最好还是把这些注解写在getter上
  @Id
  @GeneratedValue    
  private int id;
  private String name;
  @OneToOne(mappedBy="b")//双向一对一关联以A类的b属性配置来进行关联
  private A a;
  //setter  getter......
}


------ Solution -------------------------- ------------------
not hibernate annotations can look at this document http://docs.jboss.org/hibernate/annotations/3.4/reference/ zh_cn / html_single /
------ For reference only ---------------------------------- -----


is to B as it is an attribute of A
That comment how to write ?
------ For reference only ------------------------------------ ---


give a simple example you
------ For reference only --------------------------- ------------
you search on the Internet , many are
------ For reference only --------------- ------------------------


I could not find a satisfactory asked to come to this . . .
------ For reference only ---------------------------------------


Well I write mainly on getter on the property too lazy to play on my first try and see. .
------ For reference only -------------------------------------- -


OK solved. . . Thank you. .

Memcache how the key management

 This post last edited by the Anders_Zhuo on 2013-11-04 23:36:59
I do back in the game development companies, some data will be temporary to memcache

But when it came to developing such a question:

lot of background development in their own writing extension classes which use memcahce, will declare their own key.

Thus, for me to write my extended class, to use memcache, declared key , I was a bit tangled

I do not know which key has been used , I can not go to other people , I read through the code and see what key has been used. This is too cumbersome

Ever since, I do not know how to do ?

sum up the problem :

1 memcache the key how to manage it, is to put all the key are written in a separate statement inside a class , or write in a configuration file, so if you use a key which others can know . . Or are there better ways ? ? ? ?

For example, class A which has the code : memcache.set ("key1", value); memcache.set ("key2", value2);
< br /> then class B which also has some of this code , memcache.set ("key3", value); memcache.set ("key4", value2);

also there are class C, class D , and so too much

so I set method when I do not know which key has been used by others .


2 memcache now there are a lot of data , and also can not be deleted , I want to know what key, how do you know ? ?
I checked on the Internet , there is a way a lot of trouble :
telnet connection memcache, stats items, then stats item index 0 this will put all the key listed, but it feels a lot of trouble , there is no other way to know what has been using key????




------ Solution ------------------------------------ --------

first, your avatar protest.
key statement for each project should have its own rules , your own set like.
The easiest way : project name , delimiter , the module name , delimiter, function name , delimiter , key you use. Small projects unlikely to repeat .
------ For reference only -------------------------------------- -


Under this you ask my colleagues should give you answer it
------ For reference only ------------------- --------------------
does this thing do not need to go global constraints , or interact with a few per cent more cache , each upper application to make a conventions like
------ For reference only ---------------------------------- -----
this comparison approach is to do kung fu provincial convention slightly, to achieve perfect configuration is quite troublesome cough is not considered half-baked
------ For reference only ---------------------------------------
All are written in the same key the next class like, ah , you need to go to class adds new content under Key , of course, everyone put their use in a range of key inside, so it will not conflict .
------ For reference only -------------------------------------- -

first, your avatar protest.      
key statement for each project should have its own rules , your own set like.   
The easiest way : project name , delimiter , the module name , delimiter, function name , delimiter , key you use. Small projects unlikely to repeat .  

this picture , I spent a whole year now ! Protest is invalid !

[ Java TCP congestion problems ... online ... ] There are no good people to help me find out why this code will block ah ?

Recently read a book "Java TCP / IP Socket" The book explains some of the content on the Socket , which saw the content on obstruction after a little would not understand, you can not help me look at the code , why is there blocking ah ?

example , there are two cases, case 1 : will not clog ; case 2 : will be blocked ;

code is as follows :

//客户端
public class CompressClient
{
    public static final int BUFSIZE = 256;

    public static void main(String[] args) throws IOException
    {
        InetAddress inetAddr = InetAddress.getLocalHost();
        int port = 8888;
        String fileName = "D:\\杂乱\\桌面.jpg";

        FileOutputStream fileOut = new FileOutputStream(fileName + ".gz");
        final FileInputStream fileIn = new FileInputStream(new File(fileName));

        final Socket sock = new Socket(inetAddr, port);

        // 情况一:不会出现阻塞
        // Thread thread = new Thread()
        // {
        // @Override
        // public void run()
        // {
        // try
        // {
        // sendBytes(sock, fileIn);
        // }
        // catch (IOException e)
        // {
        // e.printStackTrace();
        // }
        // }
        // };

        // thread.start();

        // 情况二:会出现阻塞
        sendBytes(sock, fileIn);

        // 接收压缩服务器信息
        InputStream sockIn = sock.getInputStream();
        int bytesRead;
        byte[] buffer = new byte[BUFSIZE];
        while ((bytesRead = sockIn.read(buffer)) != -1)
        {
            fileOut.write(buffer, 0, bytesRead);
            System.out.print("R");
        }
        System.out.println();

        fileIn.close();
        fileOut.close();
        sock.close();
    }

    private static void sendBytes(Socket socket, InputStream fileIn)
            throws IOException
    {
        OutputStream sockOut = socket.getOutputStream();
        int bytesRead = 0;
        byte[] buffer = new byte[BUFSIZE];
        while ((bytesRead = fileIn.read(buffer)) != -1)
        {
            sockOut.write(buffer, 0, bytesRead);
            System.out.print("W");
        }
        System.out.println("\nClient send data complete!");
        socket.shutdownOutput();
        System.out.println("Client is deadlock? No");
    }
}


//服务端
public class TCPEchoServerExecutor
{
    public static void main(String[] args) throws IOException
    {
        int echoServProt = 8888;

        ServerSocket servSock = new ServerSocket(echoServProt);
        Logger logger = Logger.getLogger("practical");
        Executor service = Executors.newCachedThreadPool();

        while (true)
        {
            Socket clntSock = servSock.accept();
            service.execute(new CompressProtocol(clntSock, logger));
        }
    }
}


//线程任务类
public class CompressProtocol implements Runnable
{
    public static final int BUFSIZE = 1024;

    private Socket clntSock;

    private Logger logger;

    public CompressProtocol(Socket clntSock, Logger logger)
    {
        this.clntSock = clntSock;
        this.logger = logger;
    }

    public static void handleCompressClient(Socket clntSock, Logger logger)
    {
        try
        {

            InputStream in = clntSock.getInputStream();
            GZIPOutputStream out = new GZIPOutputStream(
                    clntSock.getOutputStream());

            byte[] buffer = new byte[BUFSIZE];
            int bytesRead;
            while ((bytesRead = in.read(buffer)) != -1)
            {
                out.write(buffer, 0, bytesRead);
            }
            out.finish();

            logger.info("Server:" + clntSock.getRemoteSocketAddress()
                    + " finished");
        }
        catch (IOException e)
        {
            logger.log(Level.WARNING, "Exception in echo protocol", e);
        }

        try
        {
            clntSock.close();
        }
        catch (IOException e)
        {
            logger.info("Exception = " + e.getMessage());
        }

    }

    @Override
    public void run()
    {
        handleCompressClient(clntSock, logger);
    }
}


Two commented the situation , but the use of a code , it will not be blocked . This is what principle ah ? We can explain the explanation?
------ Solution ---------------------------------------- ----
  
private static void sendBytes (Socket socket, InputStream fileIn)
throws IOException
{
OutputStream sockOut = socket.getOutputStream ();
int bytesRead = 0;
byte [] buffer = new byte [BUFSIZE];
while ((bytesRead = fileIn.read (buffer))! = -1) / / Here will be blocked because if there is no bytes are read , then blocked
{
sockOut.write (buffer, 0, bytesRead);
System.out.print ("W");
}
System.out.println ("\ nClient send data complete!");
socket.shutdownOutput ();
System.out.println ("Client is deadlock No?");
}
The code in question ,
------ Solution ------------------------------ --------------

//不管是客户机,还是服务器程序,你这段代码只能是学习用, 要用到项目中去, 不能这么简单的写.
while ((bytesRead = in.read(buffer)) != -1)
            {
             out.write(buffer, 0, bytesRead);
}

use the following code, and then improve their own :

try{

int pava=0;
int cava=0;
int sumb=0;
int i=0;
int c=0;
ByteArrayOutputStream buffeOut =new ByteArrayOutputStream();
byte readbuf[] = new byte[10240];
while (socket.isConnected() && !socket.isClosed()) {
i++;
pava =in.available();
if(pava>0){
while ((c = in.read(readbuf)) != -1) {
buffeOut.write(readbuf, 0, c);
sumb =sumb + c;
cava =in.available();
if(cava<=0){
Thread.sleep(100);
cava =in.available();
if(cava<=0) break;
}
}
String strin = new String(buffeOut.toByteArray(),"utf-8");
System.out.println("读取流数据内容: "+strin+","+sumb);
buffeOut.reset();
//读完后回复信息.
out.write((i+",我是服务器,已收到数据!").getBytes("utf-8"));
out.flush();
if(c == -1) break;//对方关闭了输入流.
}else{
sumb=0;
out.write((i+",我是服务器,请发送数据!").getBytes("utf-8"));
out.flush();
Thread.sleep(1000);
}
}
} catch (SocketException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
System.out.println("Request,NO["+requestCount+"],读取流数据完成.");
}

------ For reference only ----------------------------------- ----
answer is no well-wishers it? Online ......
------ For reference only ---------------------------- -----------
right, I ask you to send queue and (RecvQ) receive queue size is how much ah TCP socket (SendQ) in ?
------ For reference only ---------------------------------------
read the socket read ! (buffer) = -1 only in one case established that in each call socket.shutdownOutput (); methods.
-1 otherwise never have occurred , so you never end here , unless two conditions:
1 each call socket.shutdownOutput () ;/ / You will receive a -1 , but if the other program is not what you write , can not guarantee oh.
2 each call socket.close (); / / there is an exception, the end , but when you have to re- write data anomalies appear
-----!! - For reference only ---------------------------------------


Thank you, my own problems to solve , first you will good, but one thing you analyze wrong, when calling sockOut.write (buffer, 0, bytesRead), I found that the program is here was only blocked , indicating that - " receiving end SendQ queue has been filled , so will cause obstruction when the server calls sockOut.write (buffer, 0, bytesRead)", this problems with "Socket receive queue SendQ" about !

However, there still want to thank you , while ((bytesRead = in.read (buffer))! = -1) is used in this way depends on what the scene , You can also use the " custom message boundary character " to achieve .

Thank you !
------ For reference only -------------------------------------- -


"! socket in the read (buffer) = -1 only established in one case ," you say this view is wrong , the correct view is : Only two views establishment , 1.socket.shutdownOutput () 2.socket.close (), I suggest you try it yourself !
------ For reference only -------------------------------------- -
I'm here to write the code , just learning to use , does not suggest that you direct use projects, is just learning to use Oh !
correct code is as follows :

/*
 * 服务端
 */
public class TestServer
{
    public static void main(String[] args) throws IOException
    {
        System.out.println("服务端启动......");
        ServerSocket server = new ServerSocket(8888);

        Socket client = server.accept();
        OutputStream output = client.getOutputStream();
        InputStream input = client.getInputStream();

        byte[] temp = new byte[10];
        int realLen = 0;
        while ((realLen = input.read(temp)) != -1)
        {
            System.out.println("【服务端】正在发送数据......");
            output.write(temp, 0, realLen);
        }
        System.out.println("【客户端】发送数据完毕!");
        output.flush();

        client.close();
    }
}




/*
 * 客户端
 */
public class TestClient
{
    public static void main(String[] args) throws UnknownHostException,
            IOException
    {
        System.out.println("客户端启动......");
        final Socket client = new Socket(InetAddress.getLocalHost(), 8888);

        final OutputStream out = client.getOutputStream();
        InputStream in = client.getInputStream();
        final FileInputStream fileIn = new FileInputStream(new File(
                "D:\\杂乱\\桌面.jpg"));

        // 使用一个子线程发送数据
        Thread handlerExecute = new Thread()
        {
            @Override
            public void run()
            {
                try
                {
                    byte[] fileTemp = new byte[1024];
                    int realFileLen = 0;

                    while ((realFileLen = fileIn.read(fileTemp)) != -1)
                    {
                        System.out.println("【客户端】正在发送数据......");
                        out.write(fileTemp, 0, realFileLen);
                    }
                    System.out.println("【客户端】发送数据完毕!");

                    out.flush();
                    client.shutdownOutput();
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
        };

        handlerExecute.start();

        // 使用主线程接收数据
        ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
        int realLen = 0;
        byte[] temp = new byte[10];
        while ((realLen = in.read(temp)) != -1)
        {
            byteArray.write(temp, 0, realLen);
        }
        byte[] recvByte = byteArray.toByteArray();

        System.out.println("客户端接收消息成功,消息长度:" + recvByte.length);

    }
}

everything there intact ! Thank guishuanglin again !!!

What does this mean

Regular expression (?! \ \ D) What is the meaning
------ Solution -------------------------- ------------------
this is called negative lookahead , represents the right location can not figure
------ For reference only --- ------------------------------------
etc. downstairs to answer ....
------ For reference only ---------------------------------------

Do not be so wet bar . .
------ For reference only -------------------------------------- -

probably know, test it, just do the right limit , which it does not match the results
------ For reference only ---------- -----------------------------
this is a non-capturing group , not numbers match back position.
------ For reference only -------------------------------------- -
\ d matches a digit character. Equivalent to [ 0-9 ] .
(?! \ \ d) positive negative pre-investigation, the figures do not match any string of characters at the beginning of the search string match . This is a non-matching , that is, the match does not need access to for future use . For example, "Windows (95 |?! 98 | NT | 2000)" matches "Windows3.1" in the "Windows", but can not match "Windows2000" in "Windows".
------ For reference only -------------------------------------- -
upstairs positive solution. . .

Ternary operator issues

String[] strs = new String[]{"", null, "1", "a", "1   ", "a  ", "   1", "    a"};

String str;

for (int i = 0; i < strs.length; i++) {
str = "92=" + strs[i] == null ? "" : strs[i] + "|";
System.out.println(i + "\t[" + str + "]");
}


After execution , the previous " 92 =" how no ?
------ Solution ----------------------- ---------------------
str = "92=" + strs[i] == null ? "" : strs[i] + "|";
changed
str = "92=" + (strs[i] == null ? "" : strs[i]) + "|";

------ Solution ------------------------------------- -------
because the ternary operator : ? precedence than the binary + operator is low, add operations to run , so in fact the above formula is equal to:
str = (("92 =" + strs [i]) == null) "":? strs [i] + "|";
first computing the sum + , and then determine whether the string is equal to the sum of the null.

landlord does want to express :
str = "92 =" + ((strs [i] == null) "":? strs [ i] + "|");

so enclosed on the first run ternary operator.

jdk eclipse is not visible in the source

See seems to be class
------ Solution ---------------------------------- ----------
point that attach source, find your jdk installation src.zip directory, confirmed on the line
------ For reference only ---- -----------------------------------
ah , I have done .

2013年12月18日星期三

JNDI problem

Console error saying can not load jdbc driver
------ Solution -------------------------------- ------------
put your jdbc driver Kaodao tomcat lib folder
------ For reference only ----------- ----------------------------
 OK .

Has been applied to calls between , how to choose rpc or mq?

Ask everyone calls between the two systems , it is the choice rpc or mq, talk about it and select your system

such rpc can be a simple spring httpinvoker, but the premise is all java applications and are used spring framework,
can choose restful web service or a heavyweight soap web service,
or use rmi, or write java api socket program ;
mature soa or using third-party products, such as alibaba 's dubbo

or use mq system

But for calls between two applications , the above methods can be used, the choice of how we are , where several aspects to the choice of it ?

------ Solution ------------------------------------ --------
project used ActiveMQ, can be downloaded ActiveMQ agency services as message forwarding station , to achieve data transmission between the two applications , and ActiveMQ failover support for 32 and 64- bit operating systems are supported, in my experience is concerned , activeMQ is a good choice, you can download the first study, http://download.csdn.net/detail/baohuan_love/6683581
- ----- Solution --------------------------------------------

you that this is not analyzed very Okay , basically that's all
------ For reference only ---------------- -----------------------
there are more comments? I personally feel that if it is needed to return the data in real time , then mq field it may be irrelevant , mq advantages of asynchronous and decoupled , access needs to be sent immediately after the sending end of the scene estimated return information or rpc more suitable , we mean it

Tomcat server is installed on the computer , there System occupied port 80 issues

When installed appache tomcat server, view port occupies 360 procedures , there
, the problem of learning tomcat does not matter , but I very much want to learn how to program or get rid of the 80 -port , let him take up another port , so that the 80 -port
- ----- Solution --------------------------------------------
you first enter cmd console and enter the netstat-ano view to find occupied port 80 in the last column of the process id
Figure:
then to the Task Manager to find the corresponding process will get rid of it . Of course, if you start to get rid of it , then there is a possibility , windows will occupy port 80 is iis service (asp.net web server will use this to do it , of course, can also be another ) , so you can iis service stopped on it. In the process of doing web tomcat configuration is often used as a 80 -port , after all, so the user input ip Visit our website will not need to enter port it
------ Solution -------- ------------------------------------
quote = reference to the 7th floor huchunlinnk ; 's reply : ]
  
You say this , I have used it , id you occupied port 80 process is 4060 , not a system process , is able to kill . But my process id is 4, the system is unable to kill the process . . .  

So I said, you should go to the iis services to shut up, because this is the only service windows in the occupied port 80, you're running in cmd in xp services.msc then find close iis services , win7 then control Panel \ All control panel Items \ programs and Features - " turn on or off windows features - > internet information services will remove the checkbox

iis my side after win7 will open port 80 will be the process ID of the program to take up to four .
But these two removed on ok


------ For reference only ---------------------------------- -----
seemingly more difficult now , Microsoft is now looking
------ For reference only ---------------------------------------
hope you mean the web publish projects to the 80 port? Yes, directly to the tomcat following config folder below
server.xml modify the following code
connectionTimeout = "20000"
redirectPort = "8443" URIEncoding = "GBK" /> ;
in 8080 to 80 ports can be
------ For reference only ------------------------ ---------------
  The reply was deleted at the moderator 2013-12-12 09:17:40

------ For reference only ---------------------------------- -----

not the problem, which is not adjusted occupied tomcat server port , but the port is occupied by 80 program to get rid of , because if there is , then the program occupies port 80 , tomcat server is started up , so the program should occupy 80 port changed, let him use another port , in this case , port 80 on the idle out, so the tomcat server port 80 can be changed to the normal start up
----- - For reference only ---------------------------------------

you say this , I have used it , id you occupied port 80 process is 4060 , not a system process , is able to kill . But my process id is 4, the system is unable to kill the process . . .
------ For reference only -------------------------------------- -

you say this , I have used it , id you occupied port 80 process is 4060 , not a system process , is able to kill . But my process id is 4, the system is unable to kill the process . . .  

So I said, you should go to the iis services to shut up, because this is the only service windows in the occupied port 80, you're running in cmd in xp services.msc then find close iis services , win7 then control Panel \ All control panel Items \ programs and Features - " turn on or off windows features - > internet information services will remove the checkbox
------ For reference only ----- ----------------------------------
recommend you a software
tcpview
deal specifically with this situation you
------ For reference only -------------------------- -------------

you say this , I have used it , id you occupied port 80 process is 4060 , not a system process , is able to kill the . But my process id is 4, the system is unable to kill the process . . .          
  
So I said, you should go to the iis services to shut up, because this is the only service windows in the occupied port 80, you're running in cmd in xp services.msc then find close iis services , win7 then control Panel \ All control panel Items \ programs and Features - " turn on or off windows features - > internet information services will remove the checkbox  
I shut the IIS . . . Or no matter what . . .
------ For reference only -------------------------------------- -
I encountered this problem , System occupied port 80, is a server 2008 system, the internet can find , what I remember is to change the registry
------ For reference only --- ------------------------------------

you said this I also use over it , id you occupied port 80 process is 4060 , not a system process , is able to kill . But my process id is 4, the system is unable to kill the process . . .                
    
So I said, you should go to the iis services to shut up, because this is the only service windows in the occupied port 80, you're running in cmd in xp services.msc then find close iis services , win7 then control Panel \ All control panel Items \ programs and Features - " turn on or off windows features - > internet information services will remove the checkbox          
I shut the IIS . . . Or no matter what . . .  

off after restart the computer to remember enough
------ For reference only ------------------------ ---------------


I think the landlord said he shut iis described iis port 80 must have been occupied by the landlord should not have to restart the computer but nothing in the windows where the default port 80 is assigned to the web service on this is not necessary unless you modify the registry iis port that is anything else

------ For reference only ---------------------------------- -----

  
I think the landlord said he shut iis described iis port 80 must have been occupied by the landlord should not have to restart the computer but nothing in the windows where the default port 80 is assigned to the web service on this is not necessary unless you modify the registry iis port that is anything else   
 
iis not a problem , the process takes a 'System', not iis, iis uninstall this case is useless .
------ For reference only -------------------------------------- -

you say this , I have used it , id you occupied port 80 process is 4060 , not a system process , is able to kill . But my process id is 4, the system is unable to kill the process . . .                      
      
So I said, you should go to the iis services to shut up, because this is the only service windows in the occupied port 80, you're running in cmd in xp services.msc then find close iis services , win7 then control Panel \ All control panel Items \ programs and Features - " turn on or off windows features - > internet information services will remove the checkbox                
I shut the IIS . . . Or no matter what . . .          
  
off after restart the computer enough to remember  
has been resolved. . . Thank you restart the computer off after ......

java Swing doubts



Why is my own definition of JButton class does not correctly display ?
I think we should rewrite JButton some way?
The results are:

------ Solution ------- -------------------------------------
lz beginner swing it, go see their landlord achieve JButton, feel landlord has the idea to create the code for lz in :
1.lz own custom JButton is already added to the JFrame , but did not display button content.
2.lz To display the contents MyButton , you need to add a constructor in the MyButton class :
public MyButton(String text) {
super(text);
}

because you MyButton class contains a JButton, the JButton and you add in the JFrame MyButton not directly related , so that you created in the Test MyButton method is not displayed content.
------ Solution ---------------------------------------- ----
MyButton inherited JButton, new MyButton () to create the button name is not displayed , so the display is right on the screen.
You can try this.add (my_bt.bt);
------ Solution ------------------- -------------------------
you write something called "Creating did not add ."
------------------
your MyButton inherited JButton, meaning MyButton itself is jbutton,
your constructor super () this one is the MyButton set as the default JButton ().
At this point, you have a constructor which bt = JButton ("Save");
You probably online, do not show me this how ah ?
Yes, your bt actually exist, but your JFrame 's add () to add the MyButton, rather than bt = JButton ("Save"); That bt.
-------------------
you here actually creates three Button, but there are two added into the JFrame ...

not believe it, you can try to add Test in this sentence:
JButton bu = my_bt.bt;
this.add ();
try ...... [I just look at your code, have not tried , there is a problem ask it ... ]
------ For reference only ---------------------------------------
Thank stride _ YUAN Shen Jian , Yimenchuixue, weidu23 three answers , I just started to learn Swing, yesterday to write a panel in the project , there have this problem. Thank you for your answer ! ! !

Ask questions about exception handling

If my main method to call three methods in turn , f1 (), f2 (), f3 (). Three methods may throw an exception.
how to design exception handling can be achieved :
1. regardless of whether an exception is thrown three methods , can be executed in sequence f1, f2, f3.
2. If there is an exception in the main final play of all exception information .


------ Solution ------------------------------------ --------

feel so good as this simple :     
    

public static void main(String[] args){
   StringBuilder errMsg = new StringBuilder();
   try{
      f1();
   }catch(Exception ex){
      errMsg.append("f1()的异常信息:").append(ex.getMessage());
   }
   try{
      f2();
   }catch(Exception exx){
      errMsg.append("f2()的异常信息:").append(exx.getMessage());
   }
   try{
      f3();
   }catch(Exception exxx){
      errMsg.append("f3()的异常信息:").append(exxx.getMessage());
   }
   // 打印异常 
   System.out.println(errMsg.toString());
   
}
         
  
is not to say, if the exception is caught and handled , the program is not terminated , will continue down the order of execution ?  
yes.
unless they use the throw statement in the catch block , the exception will be caught and then thrown out , otherwise dispose of captured , it will not terminate the program at the exception occurred .
------ For reference only -------------------------------------- -
give ideas, there are pre- flash people :
public static int flagIndex = 0;
public static StringBuffer errMsg = "";
public static void main(String[] args){
   try{
      f1();
      flagIndex = 1;
      f2();
      flagIndex = 2;
      f3();
   }catch(Exception ex){
      errMsg.append(ex.getMessage());
      if(flagIndex == 0){
         try{
            f2();
            flagIndex = 3;
            f3();
         }catch(Exception exx){
            errMsg.append(exx.getMessage());
            if(flagIndex==3){
               try{
                  f3();
               }catch(Exception exxxx){
                  errMsg.append(exxxx.getMessage());
               }
            }
         }
      }else if(flagIndex == 1){
         //获取方法f2执行出现的异常信息
         errMsg.append(ex.getMessage());
         try{
            f3();
         }catch(Exception exxx){
            errMsg.append(exxx.getMessage());
         }
      }else{
          //获取方法f3执行出现的异常信息
         errMsg.append(ex.getMessage());
      }
   }finally{
      System.out.println(errMsg.toString());
   }
}

------ For reference only ----------------------------------- ----

feel so good as this simple :

public static void main(String[] args){
   StringBuilder errMsg = new StringBuilder();
   try{
      f1();
   }catch(Exception ex){
      errMsg.append("f1()的异常信息:").append(ex.getMessage());
   }
   try{
      f2();
   }catch(Exception exx){
      errMsg.append("f2()的异常信息:").append(exx.getMessage());
   }
   try{
      f3();
   }catch(Exception exxx){
      errMsg.append("f3()的异常信息:").append(exxx.getMessage());
   }
   // 打印异常 
   System.out.println(errMsg.toString());
   
}

------ For reference only ----------------------------------- ----

feel so good as this simple :   
[/ code]   ah endorsed
------ For reference only ------------------------------- --------

feel so good as this simple :   
  

public static void main(String[] args){
   StringBuilder errMsg = new StringBuilder();
   try{
      f1();
   }catch(Exception ex){
      errMsg.append("f1()的异常信息:").append(ex.getMessage());
   }
   try{
      f2();
   }catch(Exception exx){
      errMsg.append("f2()的异常信息:").append(exx.getMessage());
   }
   try{
      f3();
   }catch(Exception exxx){
      errMsg.append("f3()的异常信息:").append(exxx.getMessage());
   }
   // 打印异常 
   System.out.println(errMsg.toString());
   
}
 

is not to say, if the exception is caught and handled , the program is not terminated , will continue down the order of execution ?
------ For reference only -------------------------------------- -
floor China good IT, China good code
------ For reference only ---------------------------------------
2 Building on the good way .
------ For reference only -------------------------------------- -
when the exception is caught , the following code can proceed . Therefore, the second floor of the code is completely OK. Floor thinking too complicated.

The main exception is not done these small tests.

too lazy to write the code , on the second floor directly copy!
------ For reference only ---------------------------------------

feel so inferior so succinctly:   
  

public static void main(String[] args){
   StringBuilder errMsg = new StringBuilder();
   try{
      f1();
   }catch(Exception ex){
      errMsg.append("f1()的异常信息:").append(ex.getMessage());
   }
   try{
      f2();
   }catch(Exception exx){
      errMsg.append("f2()的异常信息:").append(exx.getMessage());
   }
   try{
      f3();
   }catch(Exception exxx){
      errMsg.append("f3()的异常信息:").append(exxx.getMessage());
   }
   // 打印异常 
   System.out.println(errMsg.toString());
   
}
 

I noticed oh_Maxy mao brother, you are in the main inside out here , if not main inside, but a private void exe () inside, so it is easy to write the problem , right?
I think add a finally {} is better ...
------ For reference only ------------------ ---------------------

feel so good as this simple :     
    

public static void main(String[] args){
   StringBuilder errMsg = new StringBuilder();
   try{
      f1();
   }catch(Exception ex){
      errMsg.append("f1()的异常信息:").append(ex.getMessage());
   }
   try{
      f2();
   }catch(Exception exx){
      errMsg.append("f2()的异常信息:").append(exx.getMessage());
   }
   try{
      f3();
   }catch(Exception exxx){
      errMsg.append("f3()的异常信息:").append(exxx.getMessage());
   }
   // 打印异常 
   System.out.println(errMsg.toString());
   
}
         
  
I noticed oh_Maxy mao brother, you are in the main inside out here , if not main inside, but a private void exe () inside, so it is easy to write the problem , right?   
I think add a finally {} is better ...  
not add finally, because each catch block has captured the exception , the equivalent internal digested .
finally dispensable .

Online , Java how to achieve the jsp page online preview document

RT
document upload done
stored in the database is to upload the document path
project needs now is to click on the document name to open the document in a jsp page, kind of like Baidu library preview
document format currently has three kinds of PPT WORD PDF
Internet to find a
Many use poi to resolve the
but currently only done parsing text and parsed out , open it slowly, so certainly not
table format and pictures are resolved not out
very tangled
There are dozens with flexpaper to convert swf file is displayed in the preview
but still could not get some of the software is not free or open source, not just with the commercial version of the software
increasingly tangled

Who do the Demo ah
Online ah
heroes
------ Solution ---------------------------------- ----------
not so simple , it is best to have a background batch upload PDF documents are unified into a format or directly open the front desk to preview the PDF.

conversion process suggested tools , not limited to the Java implementation ; their use be resolved like POI achieve efficiency is too low.
------ Solution ---------------------------------------- ----
have to use third-party plug-ins , otherwise no way do we use third-party companies are plug-ins, such as excel displayed in IE. guess you do not have an example in the search, I have found over and over the
give you an excel example , can only be used in IE , other browsers are not supported.
important is the phrase


IPA: OWCVBA11.CHM yourself to download and play it


<html xmlns="http://www.w3.org/1999/xhtml" >

<head id="Head1" runat="server">

    <title>Untitled Page</title>


     <script language="javascript"> 


function document.onkeydown(){
if(event.keyCode == 116){
event.keyCode = 0;
event.returnValue = false;
return;
}
}


if(window.Event){
   document.captureEvents(Event.MOUSEUP);
   } 
 
function nocontextmenu(){
  event.cancelBubble = true
  event.returnValue = false;
  return false;
}
 
function norightclick(e) {
 if (window.Event){
  if (e.which == 2 || e.which == 3)
    return false;
 }else if(event.button == 2 || event.button == 3) {
    event.cancelBubble = true
    event.returnValue = false;
    return false;
 }  
}
 
document.oncontextmenu = nocontextmenu;  // for IE5+
document.onmousedown = norightclick;  // for all others


function deleteRecord(){
var Spreadsheet1 = document.all("Spreadsheet1"); 
       //var rowNum = Spreadsheet1.ActiveCell.Row;
//Spreadsheet1.Cells.Rows(rowNum).Delete();
       var rowNums = Spreadsheet1.Selection.Rows;
rowNums.Delete();
}

function undo(){

var Spreadsheet1 = document.all("Spreadsheet1"); 
if(Spreadsheet1.CanUndo){
     Spreadsheet1.Undo();
}else{
     alert("无法执行撤销操作!");
}
}

function clearAll(){
var Spreadsheet1 = document.all("Spreadsheet1"); 
Spreadsheet1.Range("A2:DD500").Cells.Clear();
}

function Spreadsheet1_BeforeContextMenu(x, y, Menu, Cancel){
var cmContextMenu = new Array();
     cmContextMenu[0] = ["撤销操作(&U)", "undo"];
cmContextMenu[1] = null;
cmContextMenu[2] = ["删除行记录(&D)", "deleteRecord"];
cmContextMenu[3] = ["清空所有记录(&A)", "clearAll"];
Menu.Value = cmContextMenu;
//Cancel.Value = true;
}

function Spreadsheet1_CommandExecute(Command, Succeeded){
if(Command == 'undo')  undo();
if(Command == 'deleteRecord')  deleteRecord();
if(Command == 'clearAll')  clearAll();
}

function Spreadsheet1_BeforeKeyDown(KeyCode, Shift, Cancel){
//屏蔽剪切复制
if((Shift == 2) && (KeyCode == 88 || KeyCode == 67)) Cancel.Value = true;
}

function   onload()   { 

var   Spreadsheet1   =   document.all("Spreadsheet1"); 
Spreadsheet1.EnableUndo = false;
//设置显示工具栏
Spreadsheet1.DisplayToolbar = false;

//设置调整大小
Spreadsheet1.ActiveWindow.EnableResize = false;

//alert(arr.length);

//显示"命令和选项"窗口
Spreadsheet1.AllowPropertyToolbox =  false;

//设置单个sheet属性
Spreadsheet1.DisplayWorkbookTabs = true; 

var aa = eval("Spreadsheet1"+"_BeforeContextMenu");
//调用事件
Spreadsheet1.attachEvent("BeforeContextMenu",aa); 
Spreadsheet1.attachEvent("CommandExecute",Spreadsheet1_CommandExecute); 
Spreadsheet1.attachEvent("BeforeKeyDown",Spreadsheet1_BeforeKeyDown); 


      Spreadsheet1.ActiveSheet.Cells.Clear();
      Spreadsheet1.ActiveSheet.Cells(2, 1).Value = "Car";
      Spreadsheet1.ActiveSheet.Cells(3, 1).Value = "Sport-Utility";
      Spreadsheet1.ActiveSheet.Cells(4, 1).Value = "Truck";
      Spreadsheet1.ActiveSheet.Cells(5, 1).Value = "Minivan";


      Spreadsheet1.ActiveSheet.Cells(1, 2).Value = "1998";
      Spreadsheet1.ActiveSheet.Cells(2, 2).Value = 0.2;
      Spreadsheet1.ActiveSheet.Cells(3, 2).Value = 0.06;
      Spreadsheet1.ActiveSheet.Cells(4, 2).Value = 0.17;
      Spreadsheet1.ActiveSheet.Cells(5, 2).Value = 0.13;

      Spreadsheet1.ActiveSheet.Cells(1, 3).Value = "1999";
      Spreadsheet1.ActiveSheet.Cells(2, 3).Value = 0.38;
      Spreadsheet1.ActiveSheet.Cells(3, 3).Value = 0.82;
      Spreadsheet1.ActiveSheet.Cells(4, 3).Value = 0.28;
      Spreadsheet1.ActiveSheet.Cells(5, 3).Value = 0.62;

      Spreadsheet1.ActiveSheet.Cells(1, 4).Value = "2000";
      Spreadsheet1.ActiveSheet.Cells(2, 4).Value = 0.42;
      Spreadsheet1.ActiveSheet.Cells(3, 4).Value = 0.12;
      Spreadsheet1.ActiveSheet.Cells(4, 4).Value = 0.55;
      Spreadsheet1.ActiveSheet.Cells(5, 4).Value = 0.25;

      
    //设置保护区域
    var shtCurrent = Spreadsheet1.ActiveSheet;    

     var rngUsed = shtCurrent.UsedRange;

var rngCurRegion = Spreadsheet1.Range("a2").CurrentRegion;

   alert(rngUsed.Rows.Count);
   //alert(rngUsed.Columns.Count);
//Spreadsheet1.Cells.Rows(2).Delete();

    //shtCurrent.range(shtCurrent.Cells(5, 1),shtCurrent.Cells(5, 4)).Locked = false;
    //shtCurrent.Protection.Enabled = true;

Spreadsheet1.EnableUndo = true;

//alert(Spreadsheet1.XMLData);

    //alert(Spreadsheet1.ActiveWorkbook.XmlMaps(1).MapData);




</script> 

</head>

<body onload="return onload()" >

<form id="form1" runat="server">
<div>  
</div>
</form>

<OBJECT  id="Spreadsheet1" classid="clsid:0002E559-0000-0000-C000-000000000046" name="Spreadsheet1" style="width:100%;height:421px" > 

            <table width="100%" cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td bgcolor="#336699" height="25" width="10%">&nbsp;</td>
                    <td bgcolor="#666666" width="85%">
                        <font face="宋体" color="white" size="4">
                            <b>&nbsp; 缺少 Microsoft Office Web Components</b>
                        </font>
                    </td>
                </tr>
                <tr>
                    <td bgcolor="#cccccc" width="15">&nbsp;</td><td bgcolor="#cccccc" width="500px"><br>
                     <font face="宋体" size="2">此网页要求 Microsoft Office Web Components。
                         <p align="center">
                             <a href="C:/IUware Online/Microsoft Office Professional Enterprise Edition 2003/files/owc11/setup.exe"> 单击此处安装 Microsoft Office Web Components。
                              </a>.
                          </p>
                      </font>
                      <p>
                      <font face="宋体" size="2"> 此网页同时要求 Microsoft Internet Explorer 5.01 或更高版本。</p>
                        <p align="center"/><a href="http://www.microsoft.com/windows/ie/default.htm"> 单击此处安装最新的 Internet Explorer</a>.
                      </font><br>&nbsp;
                    </td>
                  </tr>
              </table>

</OBJECT>
</body>

</html>


------ Solution ------------------------------------- -------
1. use openoffice to pdf convert . swf
2.jsp used flexpaper open . swf file
------ Solution -------------------------- ------------------


correct.
I said before how I deal with :
1. user uploaded word, xls, ppt, pdf after such original documents processed in the background , if not pdf format are converted into pdf format with openoffice
2. obtained in the first step of pdf files can be converted by this tool into the corresponding pdf2swf.exe swf
3. step used in jsp flexpaper generated can preview the swf

OK
------ Solution ----------------------------------- ---------
our items are third-party tools to pay
------ Solution ----------------- ---------------------------
ask your question solved? I have to solve this problem , can help me ?
------ Solution ---------------------------------------- ----
reference openOffice swftools done before
send you a link http://www.cnblogs.com/star-studio/archive/2011/12/09/2281807.html

------ Solution ------------------------------------ --------
should also have some weboffice plug it, with a commercial version of the company 's gold grid control , compatible with what are good
------ Solution ------ --------------------------------------
not so much trouble now , java can be achieved ah. Oh, I've done :

window.onload = function() { 
        
            document.getElementById("divwrapped").innerHTML = "<iframe width='100%' height='100%' src='ajax_pageload.action?path=" + encodeURIComponent(filepath) + "' />";    };


Then in the background : ( write only the key code oh )
response.setHeader("Content-type","application/vnd.openxmlformats-officedocument.wordprocessingml.document");
// 设置下载头信息 
try {
TransmitFile.downLoad(response, strUrl);
response.flushBuffer();
} catch (Exception e) {
e.printStackTrace();
 } 
out.flush();
out.close();



  /**
 * 下载文件
 * @param config
 * @param response
 * @param downLoadFileName
 */
public static void downLoad(HttpServletResponse response,String filePath){
BufferedInputStream bis=null;
BufferedOutputStream  bos=null;
try{
 String filename=filePath.substring(filePath.lastIndexOf("/") + 1, filePath.length());
 response.setContentType("application/x-msdownload");
 response.setHeader("Content-Disposition","filename="+new String(filename.getBytes("gb2312"),"iso8859-1"));
 bis =new BufferedInputStream(new FileInputStream(filePath));
 bos=new BufferedOutputStream(response.getOutputStream()); 
 byte[] buff = new byte[2048];
 int bytesread;
 while(-1 != (bytesread = bis.read(buff, 0, buff.length))) {
  bos.write(buff,0,bytesread);
 }
}catch(Exception e){
     e.printStackTrace();
}finally {
 if (bis != null)
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
 if (bos != null)
try {
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}

      
}

------ Solution ------------------------------------- -------
flexpaper this plugin, I personally think it is very easy to use , have used before .
------ Solution ---------------------------------------- ----
determine if the type of office documents
1. Through openoffice convert files to pdf
2. speaking through swftools convert pdf files into swf format
3. browse through flex web

------ Solution ------------------------------------ --------
top 1L, my suggestion is that if the requirements are not particularly stringent , uniform turn into a pdf document , the front page with adobe reader plug-in to the online preview pdf documents, such as we have just done demand
------ Solution --------------------------------------- -----
nb plugin AC_FL_RunContent
------ For reference only ------------------------ ---------------
may not help you, this thing is done to make money , it is impossible free
------ For reference only - --------------------------------------


Thank you for your help
I imagine the way
------ For reference only ------------------------------ ---------


Demo Or you can give a good example of not before , now on-line project hurry , hurry ah
Thank
------ For reference only --------------------------------- ------
directly open pdf achieved through the online preview, how not ?
------ For reference only -------------------------------------- -
landlord seeking to achieve the right demo grateful ah ah. . . .
------ For reference only -------------------------------------- -
my mailbox 454402218@qq.com
------ For reference only -------------------------- -------------
openoffice and flexpaper to use this combination to achieve . . I study two days before good ! ! Also need to install a few things. . There needs to be sent to you. . .
------ For reference only -------------------------------------- -
above world can only preview the document , if you want to preview documents in other formats , add their own judgment, and then set the header information.


 if(".DOC" .equals(extName)){response.setHeader("Content-type", "application/msword");}
 else if(".DOCX" .equals(extName)){response.setHeader("Content-type","application/vnd.openxmlformats-officedocument.wordprocessingml.document");}
 else if(".PDF" .equals(extName)){response.setHeader("Content-type","application/pdf");}
 else if(".TXT" .equals(extName)){response.setHeader("Content-type","text/html");}
 else if(".XLS" .equals(extName)){response.setHeader("Content-type","application/vnd.ms-excel");}
 else if(".XLSX" .equals(extName)){response.setHeader("Content-type","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");}
 else if(".PPT" .equals(extName)){response.setHeader("Content-type","application/vnd.ms-powerpoint");}
 else if(".PPTX" .equals(extName)){response.setHeader("Content-type","application/vnd.openxmlformats-officedocument.presentationml.presentation");}
 else if(".BMP" .equals(extName)){response.setHeader("Content-type","image/bmp");}
 else if(".GIF" .equals(extName)){response.setHeader("Content-type","image/gif");}
 else if(".IEF" .equals(extName)){response.setHeader("Content-type","image/ief");}
 else if(".JPEG" .equals(extName)){response.setHeader("Content-type","image/jpeg");}
 else if(".JPG" .equals(extName)){response.setHeader("Content-type","image/jpeg");}
 else if(".PNG" .equals(extName)){response.setHeader("Content-type","image/png");}
 else if(".TIFF" .equals(extName)){response.setHeader("Content-type","image/tiff");}
 else if(".TIF" .equals(extName)){response.setHeader("Content-type","image/tif");

------ For reference only ----------------------------------- ----

look it troublesome to me thank my mailbox 454402218@qq.com
------ For reference only ------- --------------------------------
has been sent to your mailbox. . .
------ For reference only -------------------------------------- -
can send it to my mailbox , I also do this , 365834556@qq.com, grateful
------ For reference only ------------- --------------------------

Before adopting
done this way , but the function is not very powerful.
------ For reference only -------------------------------------- -
landlord , you can send to my mail? I'm looking for this , 1525950302@qq.com grateful
------ For reference only ------------------------ ---------------
landlord, also send me free copies Oh , flexpaper use always reach the desired effect
2633522342@qq.com
------ For reference only ----------------------------- ----------
landlord , you can send to my mail? I'm looking for this , 602749539@qq.com grateful
------ For reference only ---------------------- -----------------
this online viewing . I personally feel that depends on how you are planning : 1 , online documents, so that after the display . 2 , deal with the next line of the document , online direct display .
willing to invest , get hold of the commercial code, and convenient. Refused to vote the money , how simple and how to do .
purely with people views.
------ For reference only -------------------------------------- -
landlord , you can send to my mail? I'm looking for this , 88165868@qq.com grateful
------ For reference only ---------------------- -----------------
read a pdf using iText to read data from the database when generating pdf quickly, and as long as the client installed adobe flash basic can online preview.
If only online preview iText basically no problem .
iText support picture form displayed.
------ For reference only -------------------------------------- -

752915708@qq.com trouble appreciate a copy of it ! ! !
------ For reference only -------------------------------------- -
studied flexpaper, basically based on third-party tools to achieve them will be relatively simple, but do not know if you have not found the file flexpaper only access to the project directory and can not access local files ( such as the file uploaded on the D drive ) to achieve the landlord did not know , or have solved this problem brothers seeking examples ~ 691226682@qq.com
------ For reference only ----- ----------------------------------
are learning , like to refer to demo, I hope my dear friend sent me a grateful brother . 784773798@qq.com
------ For reference only --------------------------------- ------

ie how I can only preview ah , Firefox will not be in , ah, please guide us , thank you
------ For reference only - -------------------------------------
957581081@qq.com trouble to send a recently the company to the task bar , be grateful ! ! !
------ For reference only -------------------------------------- -
wq_1108@qq.com
seeking code ah
------ For reference only ------------------------------- --------
today found a very good document preview online service, you can install your own server , REST interface calls , pure html page, the browser compatibility is very good, in the phone , tablet and computer adaptive perfect preview of different terminals , 1M about the document completely free , recommended for everyone, Website : www.idocv.com
------ For reference only ------------- --------------------------
pro said that you did , give or sub- dome , said the next item? yaodk@neusoft.com
------ For reference only --------------------------------- ------


I need , thank you !
dhdream@126.com

------ For reference only ---------------------------------- -----

  
I need , thank you !   
dhdream@126.com   
 

I also need to thank the 877344151@qq.com
------ For reference only ------------------- --------------------


seeking example , 877344151@qq.com
------ For reference only ------------------------ ---------------
seeking examples , thank you 877344151@qq.com
------ For reference only - -------------------------------------

  
I need , thank you !   
dhdream@126.com   
  with the request, thank you ! ! ! 516412376@qq.com
------ For reference only ------------------------------- --------
seeking to share ! ! !
982910864@qq.com
------ For reference only ----------------------------- ----------
give me a copy of it , 317335525@qq.com. Thank you !