Java GWT&x2B;弹簧&x2B;休眠错误404
当我尝试向服务器发送消息时,我得到错误404。 请帮我解决这个问题 向服务器发送请求:1名称Sname作业服务器答复:An 尝试联系服务器时出错。请查收 请检查您的网络连接,然后重试。错误是: com.google.gwt.user.client.rpc.StatusCodeException:404 HTTP错误: 404 找不到 RequestURI=/gwtspringtestnomaven/springwtservices/employeeService 由码头提供动力:// 我的代码: web.xml:Java GWT&x2B;弹簧&x2B;休眠错误404,java,xml,spring,gwt,servlets,Java,Xml,Spring,Gwt,Servlets,当我尝试向服务器发送消息时,我得到错误404。 请帮我解决这个问题 向服务器发送请求:1名称Sname作业服务器答复:An 尝试联系服务器时出错。请查收 请检查您的网络连接,然后重试。错误是: com.google.gwt.user.client.rpc.StatusCodeException:404 HTTP错误: 404 找不到 RequestURI=/gwtspringtestnomaven/springwtservices/employeeService 由码头提供动力:// 我的代码:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>springGwtRemoteServiceServlet</servlet-name>
<servlet-class>org.spring4gwt.server.SpringGwtRemoteServiceServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>springGwtRemoteServiceServlet</servlet-name>
<url-pattern>/com.javacodegeeks.Gwtspringtestnomaven/springGwtServices/*</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Gwtspringtestnomaven.html</welcome-file>
</welcome-file-list>
</web-app>
Gwtspringtestnomaven.html:
<!doctype html>
<!-- The DOCTYPE declaration above will set the -->
<!-- browser's rendering engine into -->
<!-- "Standards Mode". Replacing this declaration -->
<!-- with a "Quirks Mode" doctype is not supported. -->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- -->
<!-- Consider inlining CSS to reduce the number of requested files -->
<!-- -->
<link type="text/css" rel="stylesheet" href="Gwtspringtestnomaven.css">
<!-- -->
<!-- Any title is fine -->
<!-- -->
<title>Web Application Starter Project</title>
<!-- -->
<!-- This script loads your compiled module. -->
<!-- If you add any GWT meta tags, they must -->
<!-- be added before this line. -->
<!-- -->
<script type="text/javascript"language="javascript" <!-- здесь кст пишет :Attribute (language) is obsolete. Its use is discouraged in HTML5 documents. -->
src="gwtspringtestnomaven/gwtspringtestnomaven.nocache.js"></script>
</head>
<!-- -->
<!-- The body can have arbitrary html, or -->
<!-- you can leave the body empty if you want -->
<!-- to create a completely dynamic UI. -->
<!-- -->
<body>
<!-- OPTIONAL: include this if you want history support -->
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
<!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
<noscript>
<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
Your web browser must have JavaScript enabled
in order for this application to display correctly.
</div>
</noscript>
<h1>Web Application Starter Project</h1>
<table align="center">
<tr>
<td colspan="2" style="font-weight:bold;">Please enter employee info (id name surname job):</td>
</tr>
<tr>
<td id="employeeInfoFieldContainer"></td>
<td id="updateEmployeeButtonContainer"></td>
</tr>
<tr>
<tr>
<td colspan="2" style="font-weight:bold;">Please enter employee id:</td>
</tr>
<tr>
<td id="employeeIdFieldContainer"></td>
<td id="retrieveEmployeeButtonContainer"></td>
</tr>
<tr>
<td colspan="2" style="color:red;" id="errorLabelContainer"></td>
</tr>
</table>
</body>
</html>
Web应用程序启动程序项目
src=“gwtspringtestnomaven/gwtspringtestnomaven.nocache.js”
您的web浏览器必须启用JavaScript
以使此应用程序正确显示。
Web应用程序启动程序项目
请输入员工信息(id姓名职务):
请输入员工id:
您的Spring服务servlet映射包括一个包名:/com.javacodegeeks.Gwtspringtestnomaven/springwtservices/*
。您的请求URI使用与webb应用程序名称相对应的短名称:RequestURI=/gwtspringtestnomaven/springGwtServices/employeeService
。解决方案:修复servlet映射,使其指向正确的位置。/com.javacodegeeks.Gwtspringtestnomaven/springGwtServices/*vs.RequestURI=/Gwtspringtestnomaven/springGwtServices/employeeService
?谢谢!没有更多的错误404!!但是现在我得到了错误500 java.lang.NoClassDefFoundError:org/apache/log4j。我自己也很喜欢这个玩具!好的,很高兴这有帮助,我当时回答了。
package com.javacodegeeks.shared.services;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.javacodegeeks.shared.dto.EmployeeDTO;
public interface EmployeeServiceAsync {
void deleteEmployee(long employeeId, AsyncCallback<Void> callback);
void findEmployee(long employeeId, AsyncCallback<EmployeeDTO> callback);
void saveEmployee(long employeeId, String name, String surname,
String jobDescription, AsyncCallback<Void> callback);
void saveOrUpdateEmployee(long employeeId, String name, String surname,
String jobDescription, AsyncCallback<Void> callback);
void updateEmployee(long employeeId, String name, String surname,
String jobDescription, AsyncCallback<Void> callback);
public static final class Util
{
private static EmployeeServiceAsync instance;
public static final EmployeeServiceAsync getInstance()
{
if ( instance == null )
{
instance = (EmployeeServiceAsync) GWT.create( EmployeeService.class );
ServiceDefTarget target = (ServiceDefTarget) instance;
target.setServiceEntryPoint( GWT.getModuleBaseURL() + "springGwtServices/employeeService " );
}
return instance;
}
private Util()
{
// Utility class should not be instanciated
}
}
}
package com.javacodegeeks.server.services;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.javacodegeeks.server.dao.EmployeeDAO;
import com.javacodegeeks.shared.dto.EmployeeDTO;
import com.javacodegeeks.shared.services.EmployeeService;
@Service("employeeService")
public class EmployeeServiceImpl implements EmployeeService {
@Autowired
private EmployeeDAO employeeDAO;
@PostConstruct
public void init() throws Exception {
}
@PreDestroy
public void destroy() {
}
public EmployeeDTO findEmployee(long employeeId) {
return employeeDAO.findById(employeeId);
}
@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)
public void saveEmployee(long employeeId, String name, String surname, String jobDescription) throws Exception {
EmployeeDTO employeeDTO = employeeDAO.findById(employeeId);
if(employeeDTO == null) {
employeeDTO = new EmployeeDTO(employeeId, name,surname, jobDescription);
employeeDAO.persist(employeeDTO);
}
}
@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)
public void updateEmployee(long employeeId, String name, String surname, String jobDescription) throws Exception {
EmployeeDTO employeeDTO = employeeDAO.findById(employeeId);
if(employeeDTO != null) {
employeeDTO.setEmployeeName(name);
employeeDTO.setEmployeeSurname(surname);
employeeDTO.setJob(jobDescription);
}
}
@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)
public void deleteEmployee(long employeeId) throws Exception {
EmployeeDTO employeeDTO = employeeDAO.findById(employeeId);
if(employeeDTO != null)
employeeDAO.remove(employeeDTO);
}
@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)
public void saveOrUpdateEmployee(long employeeId, String name, String surname, String jobDescription) throws Exception {
System.out.println("into SaveOrUpdate");
EmployeeDTO employeeDTO = new EmployeeDTO(employeeId, name,surname, jobDescription);
System.out.println("SaveOrUpdate good");
employeeDAO.merge(employeeDTO);
System.out.println(" SaveOrUpdate out");
}
}
<!doctype html>
<!-- The DOCTYPE declaration above will set the -->
<!-- browser's rendering engine into -->
<!-- "Standards Mode". Replacing this declaration -->
<!-- with a "Quirks Mode" doctype is not supported. -->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- -->
<!-- Consider inlining CSS to reduce the number of requested files -->
<!-- -->
<link type="text/css" rel="stylesheet" href="Gwtspringtestnomaven.css">
<!-- -->
<!-- Any title is fine -->
<!-- -->
<title>Web Application Starter Project</title>
<!-- -->
<!-- This script loads your compiled module. -->
<!-- If you add any GWT meta tags, they must -->
<!-- be added before this line. -->
<!-- -->
<script type="text/javascript"language="javascript" <!-- здесь кст пишет :Attribute (language) is obsolete. Its use is discouraged in HTML5 documents. -->
src="gwtspringtestnomaven/gwtspringtestnomaven.nocache.js"></script>
</head>
<!-- -->
<!-- The body can have arbitrary html, or -->
<!-- you can leave the body empty if you want -->
<!-- to create a completely dynamic UI. -->
<!-- -->
<body>
<!-- OPTIONAL: include this if you want history support -->
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
<!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
<noscript>
<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
Your web browser must have JavaScript enabled
in order for this application to display correctly.
</div>
</noscript>
<h1>Web Application Starter Project</h1>
<table align="center">
<tr>
<td colspan="2" style="font-weight:bold;">Please enter employee info (id name surname job):</td>
</tr>
<tr>
<td id="employeeInfoFieldContainer"></td>
<td id="updateEmployeeButtonContainer"></td>
</tr>
<tr>
<tr>
<td colspan="2" style="font-weight:bold;">Please enter employee id:</td>
</tr>
<tr>
<td id="employeeIdFieldContainer"></td>
<td id="retrieveEmployeeButtonContainer"></td>
</tr>
<tr>
<td colspan="2" style="color:red;" id="errorLabelContainer"></td>
</tr>
</table>
</body>
</html>