Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

REST¼Ü¹¹ÓëJavaʵÏÖ1——REST¸ÅÄî

ÓÉÓÚÓиöºÏ×÷ÏîÄ¿£¬Óõ½ÁËREST£¬ÎÒÃÇÕâ±ßµÄ·þÎñÆ÷ÊÇjavaµÄ£¬ºÏ×÷·½ÄDZßÖ÷ÒªÊÇPHP»·¾³£¬ÎªÁËÔ¶³Ìµ÷ÓõÄÎÊÌ⣬ʹÓÃÁËREST×÷ΪAPIµÄʵÏÖ·½
°¸¡£ÏÖÔÚÏîÄ¿×öµÃ²î²»¶àÁË£¬ÏÂÃæ¼ÇÏÂ×Ô¼ºµÄÒ»µãÐĵã¬ËãÊDZʼǰɡ£
    REST£¨Representational State Transfer£©µÄ˵·¨À´×Ô“Architectural Styles and the Design of Network-based
Software Architectures”
£¨Roy Fielding£¬University of California -
Irvine£¬2000£©£¬ÊÇFielding´óÅ£µÄһƪ²©Ê¿ÂÛÎÄ£¬´ÓÍøÉÏËÑË÷ÏÂÓ¦¸Ã¿ÉÒÔÕÒµ½ÖÐÎÄ°æ¡£Ê×ÏÈREST¸ù±¾²»ÊǸö¼¼Êõ£¬Ö»ÊÇÒ»¸ö¼Ü¹¹·½Ê½µÄ×Ü
³Æ£¬¸úweb
serviceҲû̫´ó¹Øϵ£¬Ö»ÊÇ´ÕÇÉËü¿ÉÒÔÂú×ã×î¼òµ¥µÄÔ¶³ÌÐÅÏ¢»ñÈ¡µÄÐèÒª¡£RESTÒ²ÍêÈ«²»ÊÇж«Î÷£¬ÆäʵÔçÆÚµÄHTML¾²Ì¬ÍøÒ³¶¼ÊÇREST£¬Ö»²»
¹ýËæן÷ÖÖ¶¯Ì¬½Å±¾ÓïÑÔµÄʹÓ㬻¥ÁªÍøµÄ¼Ü¹¹Ò²Æ«ÀëÁËÔçÆÚµÄÉ趨£¬RESTµ¹ÊÇÓе㲦ÂÒ·´ÕýµÄζµÀ¡£
    RESTµÄÖ÷ÒªÌØÕ÷°üÀ¨£º
1£¬ËùÓеĶ«Î÷¶¼ÊÇ×ÊÔ´£¬×ÊÔ´ÓÃURI±íʾ£¬Ã¿Ò»¸ö»á»°¶¼ÊÇÎÞ״̬µÄ¡£
Õâ¾ä»°É¶Òâ˼£¬¼ÇµÃÒÔÇ°µÄ¾²Ì¬ÍøÒ³²»£¬http://localhost/hello.jspÕâʵ¼Ê¾ÍÊÇÒ»¸ö×ÊÔ´£¬Õâ¸öURI¾ÍÊÇËûµÄµØÖ·¡£Äã¿Ï
¶¨ËµÕâô¼òµ¥»¹ÓÃѧREST£¿£¬¶Ô£¬REST¾ÍÊÇÕâô¼òµ¥£¬µ«ÊÇÇé¿öÔÙ¸´ÔÓÒ»µã£¬±ÈÈçҪд¸ö¹ºÂòÉÌÆ·µÄÒ³Ã棬ÔÛÃÇÓÃJSF»òÕßstruts£¬´Óºǫ́
SessionÈ¡¸ö¿Í»§ID£¬ÔÙ´Ó¹ºÎï³µÀïÍ·°ÑÉÌÆ·ÁбíÈ¡³öÀ´£¬ÎÒÃǸßÐ˵ÄдÁËÒ»¸öhttp://localhost/buyProduct.doÍê³ÉÁË
Õâ¸ö¹¦ÄÜ£¬ÄÇôÕâ¸öhttp://localhost/buyProduct.doµÄURI¾Í²»ÊÇRESTÁË£¬ËûÒÀÀµÓÚÔËÐÐʱ»·¾³ºÍSessionÀïµÄ±ä
Á¿£¬ÕâÑùµÄURI²»Äܱ»Öظ´Ö´ÐУ¬Ò²¾ÍÊÇ˵ֱ½ÓÕ³µ½ä¯ÀÀÆ÷ÔËÐп϶¨Òª±¨´íµÄ¡£ÊDz»ÊÇRESTÒ²ºÜÈÝÒ׿´£¬ÕâÍæÒâͨ¹ýURIÄÜ·ÃÎʲ»£¬ÄÜ·ÃÎʾÍÊÇREST¡£
2£¬¹«¿ªÄ¿Â¼½á¹¹Ê½µÄ URI
¿´ÁËÉÏÃæÄǸöÀý×Ó£¬ÄÇôÔõôдÕâ¸öURIÄØ£¬ÆäʵRESTÏ£ÍûµÄURIÊDzÉÓÃĿ¼½á¹¹Ê½µÄURI£¬ÓÃÒ»ÖÖ´ø²ã´ÎµÄ½á¹¹±íʾ¶Ô×ÊÔ´µÄ»ñÈ¡£¬±ÈÈçÎÒÒª
»ñÈ¡ÂÛ̳µÄÒ»¸ötopic£¬URIµÄ¶¨Òå¾Í¿ÉÒÔ±íʾ³Éhttp://localhost/discussion/topics/103£¬ÔÚÕâÀï
topics¾ÍÊÇÉÏÎÄÎÒÃÇ˵µ½µÄ×ÊÔ´£¬ºóÃæµÄ103ÊÇ×ÊÔ´µÄID¡£ÕâÑùµÄURI¼ò½àÃÀ¹Û£¬ËÑË÷ÒýÇæÓѺ㬿ÉÒÔ±»ä¯ÀÀÆ÷»º´æ£¬Óë»á»°×´Ì¬Î޹أ¬È»ºóÄã¿ÉÄÜÒª
ÎÊÁË£¬ÄÇÎÒÒÔǰдµÄhttp://localhost/discussion/topics?id=103ÕâÑùµÄURIÄØ£¿ÆäʵÕâÖÖÒ²¿ÉÒÔËã
REST£¬URIµÄ±íʾ·½Ê½ÊÇÓÉ¿ª·¢Õß¾ö¶¨µÄ£¬µ±È»http://localhost/discussion/topics?id=103ÕâÖÖд·¨Ëƺõ¶Ô
ËÑË÷ÒýÇæ²


Ïà¹ØÎĵµ£º

java.lang.OutOfMemoryError: Java heap space

      ³öÏÖÕâ¸ö´íÎó£¬ËÑË÷µ½1¡¢ÐÞ¸Äeclipse.ini£»2¡¢Ìí¼Ó»·¾³±äÁ¿JAVA_OPTS=-Xms64m -Xmx512m£¬3¡¢ÔÚrun configurations->program argumentsÔö¼ÓXms64m -Xmx512m£¬¾ùÎÞЧ¡£
×îºó½â¾ö°ì·¨£¬ÔÚÓëprogram argumentsһǽ֮¸ôµÄVM argumentsÖÐÌí¼ÓXms64m -Xmx512m¸ã¶¨¡£ ......

¼òÒ×JAVA»ñÈ¡ÍøÒ³ÓÐЧÓÊÏäµØÖ·

//  ¼òÒ×JAVA»ñÈ¡ÍøÒ³ÓÐЧÓÊÏäµØÖ· ---by 77
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class solo7 {
 public static void main(String args[]){
   ......

ÈçºÎÓÃMyEclipseµ÷ÊÔJAVA³ÌÐò

1.ÔÚÄã¾õµÃÓдíµÄµØ·½ÉèÖöϵã
2.µã»÷¼×¿Ç³æÒ»ÑùµÄ°´Å¥ÏÂÃæµÄ×Ó°´Å¥£¬Ò²ÊǼ׿dzæÒ»ÑùµÄ£¬½ÐDebug
3.ÔËÐгÌÐò£¬µ±³ÌÐòÔËÐе½¸Õ²ÅÉèÖöϵãµÄλÖþͻáÍ£ÏÂÀ´£¬²¢ÇÒÄÇÐдúÂëµ×É«»á¸ßÁÁÏÔʾ¡£
4.½Ó×ÅÄãÔÚÈçϽçÃæÄã¿ÉÒÔ¿´µ½ÄãÏëÒªµÄÐÅÏ¢
5.ÔÚVariablesÀïÃæ¿ÉÒԲ鿴ËùÓбäÁ¿µÄÖµ£¬±ÈÈç¸Õ²ÅÉèÖõĶϵãÀïÃæµÄstrClassNameµÄÖµ¾Í ......

¹ØÓÚjavaµÄhttpЭÒéÎļþÉÏ´«ÊµÓÃÀýÌâÒ»

¹ØÓÚjavaµÄhttpЭÒéÎļþÉÏ´«ÊµÓÃÀýÌâÒ»
(2006-07-25 16:43:56)
תÔØ

 

·ÖÀࣺ
java
¹ØÓÚjavaµÄhttpЭÒéÉÏ´«:(¼òµ¥ÊµÓöøÇÒ½¡×³;Ëٶȿì)
´Ë·½·¨±ÈapacheµÄÎļþÉÏ´«°ü(uploadfile1.1:¾ÍÎļþÉÏ´«¹¦ÄܶøÑÔ)Ҫǿ¶àÁË
1.Ö»ÐèÒªÒ»¸öMultipartRequest.java»ù±¾Îļþ¾ÍÐС£
2.ǰ̨htmlµÄ»ù±¾¸ñʽ
<html ......

JAVA³£ÓòÙ×÷Óï¾ä ÏîÄ¿ÖеÄ×ܽáÈý


»ñµÃmysqlºÍoracleÁ´½ÓµÄÀà
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectDB {
private static final String MYSQL = "jdbc:mysql://";
private static final String ORACLE = "jdbc:oracle:thin:@";
private ConnectD ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ