我正在开发一个 Java RESTful Web 服务,出于某种奇怪的原因,我得到了 3 个我完全不确定的 Java 标记。
这是我的代码:
package au.com.rest; //self made package
import javax.ws.rs.*; //JaxRS
import javax.ws.rs.core.*;
import au.edu.uts.it.wsd.*; //Package containing the relevant classes
@Path("/feedlist")
public class RESTFeedService {
String name, uri, action, feedFile;
String textReply = "Feed ";
String xmlReply = "<?xml version=\"1.0\"?> \n<feeds> \n";
feedFile = "/tmp/feeds.txt";
action = request.getParameter("action");
name = request.getParameter("feedName");
uri = request.getParameter("uri");
Feed feed = new Feed(name, uri);
FeedList feedList = new FeedListImpl();
feedList.load(feedFile);
@GET
@Produces(MediaType.TEXT_PLAIN)
public String showTextFeeds()
{
for (Feed f:feedList.list()){
textReply += "[Feed Name: " + f.getName() + ", ";
textReply += "[Feed URI: " + f.getURI() + "]"; }
return textReply;
}
我得到的错误在以下几行:
String xmlReply = "<?xml version=\"1.0\"?> \n<feeds> \n";
令牌“;”上的语法错误,{ 应在此令牌之后
feedFile = "/tmp/feeds.txt";
标记“字符串”的语法错误,@ 预期
public String showTextFeeds()
令牌上的语法错误,错误的构造
请指出我做错了什么的正确方向。谢谢!