我正在尝试使用import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JPanel;
@SuppressWarnings("serial")
public class Renderer extends JPanel
{
/* (non-Javadoc)
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/
@Override
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
Simon.simon.paint((Graphics2D) g); //Simon is the first class that holds the code all the way above
}
}
将backend
应用的GWT
切换为Spring
。
我按照这个例子:
现在我想知道如何处理RestyGwt
。他们可以在客户端使用吗?我把它们放在Entities
包中,但不幸的是我收到了错误:
Shared
以下是我的课程:
客户端
gru 09, 2015 11:06:08 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Spring MVC Dispatcher Servlet] in context with path [/restgwt] threw exception [Handler processing failed; nested exception is java.lang.NoClassDefFoundError: com/google/gwt/core/client/GWTBridge] with root cause
java.lang.ClassNotFoundException: com.google.gwt.core.client.GWTBridge
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
at com.sagar.restgwt.shared.OrderConfirmation.toString(OrderConfirmation.java:18)
at java.lang.String.valueOf(String.java:2994)
at java.lang.StringBuilder.append(StringBuilder.java:131)
服务器端
@Path("/service")
public interface InfoService extends RestService {
public static class Util {
private static InfoService instance;
public static InfoService getService() {
if (instance == null) {
instance = GWT.create(InfoService.class);
}
Resource resource = new Resource(GWT.getModuleBaseURL() + "service");
((RestServiceProxy) instance).setResource(resource);
return instance;
}
}
@GET
@Path("/loadInfo")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public void getInfo(MethodCallback<OrderConfirmation> callback);
}
public void onModuleLoad() {
Button button = new Button("Click Me");
button.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
InfoService.Util.getService().getInfo(
new MethodCallback<OrderConfirmation>() {
@Override
public void onSuccess(org.fusesource.restygwt.client.Method method, OrderConfirmation response) {
RootPanel.get().add(
new Label(
"message: " + response.message + " - ready time: " + response.ready_time)
);
}
@Override
public void onFailure(org.fusesource.restygwt.client.Method method,
Throwable exception) {
// TODO Auto-generated method stub
GWT.log("Error");
}
});
}
});
共享模块
@Controller
public class RestGWTController {
@RequestMapping(value = "/loadInfo", method = RequestMethod.GET, headers = "Accept=application/json")
public @ResponseBody OrderConfirmation handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//GreetingServiceEndpoint endpoint = greetingService.getGreetingServiceEndpointPort();
OrderConfirmation confirmation = new OrderConfirmation();
//confirmation.message = endpoint.sayHello();
confirmation.message = "Hello";
confirmation.ready_time = System.currentTimeMillis() + 1000 * 60 * 30;
System.out.println("hit server");
return confirmation;
}
}
现在我考虑public class OrderConfirmation {
public String message;
public Long ready_time;
/**
* Example of how to create an instance of a JsonEncoderDecoder for a data
* transfer object.
*/
public interface OrderConfirmationJED extends JsonEncoderDecoder<OrderConfirmation> {
}
@Override
public String toString() {
if (GWT.isClient()) {
OrderConfirmationJED jed = GWT.create(OrderConfirmationJED.class);
return jed.encode(this).toString();
}
return super.toString();
}
}
模块上的DTO
和服务器上的shared
。我这是正确的。
我的问题是:
请给我一些帮助。
答案 0 :(得分:0)
您缺少gwt-servlet.jar依赖项。
Maven配置
它必须是<scope>compile</scope>
,这是默认值。其他gwt-jars可以是<scope>provided</scope>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwt.version}</version>
</dependency>