- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个由 Spring 处理的 Servlet,并且还使用 Google App Engine 作为云平台。
我想将此 Servlet 重定向到另一个页面:
@Controller
public class CustomerController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String listAllFeedsOnIndexPage(ModelMap map) throws JSONException {
return "invite";
}
@RequestMapping(method = RequestMethod.GET)
public ModelAndView add(HttpServletRequest request, ModelMap model) {
String firstName = request.getParameter("firstName");
String lastName = request.getParameter("lastName");
String email = request.getParameter("email");
System.out.println(email);
System.out.println(firstName);
System.out.println(lastName);
Customer c = new Customer();
c.setFirstName(firstName);
c.setLastName(lastName);
c.setEmail(email);
c.setDate(new Date());
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
pm.makePersistent(c);
} finally {
pm.close();
}
return new ModelAndView("redirect:thankYou");
}
My App Engine output: Initializing App Engine server Mär 30, 2013
1:28:26 PM com.google.apphosting.utils.config.EarHelper logNotAnEar
INFO: Directory 'C:\Users\user\workspace\LandingPage\war' is not an
EAR directory. File
C:\Users\user\workspace\LandingPage\war\appengine-application.xmlappengine-application.xml
not detected. Mär 30, 2013 1:28:26 PM
com.google.apphosting.utils.config.EarHelper logNotAnEar INFO:
Directory 'C:\Users\user\workspace\LandingPage\war' is not an EAR
directory. File
C:\Users\user\workspace\LandingPage\war\appengine-application.xmlappengine-application.xml
not detected. Mär 30, 2013 1:28:26 PM
com.google.apphosting.utils.config.EarHelper logNotAnEar INFO:
Directory 'C:\Users\user\workspace\LandingPage\war' is not an EAR
directory. File
C:\Users\user\workspace\LandingPage\war\appengine-application.xmlappengine-application.xml
not detected. Mär 30, 2013 1:28:26 PM
com.google.apphosting.utils.config.EarHelper logNotAnEar INFO:
Directory 'C:\Users\user\workspace\LandingPage\war' is not an EAR
directory. File
C:\Users\user\workspace\LandingPage\war\appengine-application.xmlappengine-application.xml
not detected. Mär 30, 2013 1:28:26 PM
com.google.apphosting.utils.config.AppEngineWebXmlReader
readAppEngineWebXml INFO: Successfully processed
C:\Users\user\workspace\LandingPage\war\WEB-INF/appengine-web.xml Mär
30, 2013 1:28:26 PM
com.google.apphosting.utils.config.AbstractConfigXmlReader
readConfigXml INFO: Successfully processed
C:\Users\user\workspace\LandingPage\war\WEB-INF/web.xml Mär 30, 2013
1:28:26 PM
com.google.appengine.tools.development.SystemPropertiesManager
setSystemProperties INFO: Overwriting system property key
'java.util.logging.config.file', value
'C:\Users\user\Desktop\\eclipse-java-juno-SR1-win32-x86_64\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.7.5\appengine-java-sdk-1.7.5\config\sdk\logging.properties'
with value 'WEB-INF/logging.properties' from
'C:\Users\user\workspace\LandingPage\war\WEB-INF\appengine-web.xml'
Mär 30, 2013 1:28:26 PM com.google.apphosting.utils.jetty.JettyLogger
info INFO: Logging to JettyLogger(null) via
com.google.apphosting.utils.jetty.JettyLogger Mär 30, 2013 12:28:27 PM
com.google.apphosting.utils.jetty.JettyLogger info INFO: jetty-6.1.x
Mär 30, 2013 12:28:28 PM
com.google.appengine.tools.development.ApiProxyLocalImpl log INFO:
javax.servlet.ServletContext log: Initializing Spring root
WebApplicationContext Mär 30, 2013 12:28:28 PM
org.springframework.web.context.ContextLoader
initWebApplicationContext INFO: Root WebApplicationContext:
initialization started Mär 30, 2013 12:28:29 PM
org.springframework.web.context.support.XmlWebApplicationContext
prepareRefresh INFO: Refreshing Root WebApplicationContext: startup
date [Sat Mar 30 12:28:29 UTC 2013]; root of context hierarchy Mär 30,
2013 12:28:29 PM
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions INFO: Loading XML bean definitions from
ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml] Mär 30,
2013 12:28:29 PM
org.springframework.context.annotation.ClassPathBeanDefinitionScanner
registerDefaultFilters INFO: JSR-330 'javax.inject.Named' annotation
found and supported for component scanning Mär 30, 2013 12:28:30 PM
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
<init> INFO: JSR-330 'javax.inject.Inject' annotation found and
supported for autowiring Mär 30, 2013 12:28:30 PM
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@9b4ed7a:
defining beans
[customerController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,mvcContentNegotiationManager,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,org.springframework.web.servlet.view.InternalResourceViewResolver#0,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor];
root of factory hierarchy Mär 30, 2013 12:28:31 PM
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
registerHandlerMethod INFO: Mapped
"{[],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}"
onto public org.springframework.web.servlet.ModelAndView
com.landing.controller.CustomerController.add(javax.servlet.http.HttpServletRequest,org.springframework.ui.ModelMap)
Mär 30, 2013 12:28:31 PM
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
registerHandlerMethod INFO: Mapped
"{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}"
onto public java.lang.String
com.landing.controller.CustomerController.listAllFeedsOnIndexPage(org.springframework.ui.ModelMap)
throws com.google.appengine.labs.repackaged.org.json.JSONException Mär
30, 2013 12:28:31 PM org.springframework.web.context.ContextLoader
initWebApplicationContext INFO: Root WebApplicationContext:
initialization completed in 3010 ms Mär 30, 2013 12:28:32 PM
com.google.appengine.tools.development.ApiProxyLocalImpl log INFO:
javax.servlet.ServletContext log: Initializing Spring FrameworkServlet
'mvc-dispatcher' Mär 30, 2013 12:28:32 PM
org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'mvc-dispatcher': initialization started Mär
30, 2013 12:28:32 PM
org.springframework.web.context.support.XmlWebApplicationContext
prepareRefresh INFO: Refreshing WebApplicationContext for namespace
'mvc-dispatcher-servlet': startup date [Sat Mar 30 12:28:32 UTC 2013];
parent: Root WebApplicationContext Mär 30, 2013 12:28:32 PM
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions INFO: Loading XML bean definitions from
ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml] Mär 30,
2013 12:28:32 PM
org.springframework.context.annotation.ClassPathBeanDefinitionScanner
registerDefaultFilters INFO: JSR-330 'javax.inject.Named' annotation
found and supported for component scanning Mär 30, 2013 12:28:32 PM
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
<init> INFO: JSR-330 'javax.inject.Inject' annotation found and
supported for autowiring Mär 30, 2013 12:28:32 PM
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@1d3f82cd:
defining beans
[customerController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,mvcContentNegotiationManager,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,org.springframework.web.servlet.view.InternalResourceViewResolver#0,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor];
parent:
org.springframework.beans.factory.support.DefaultListableBeanFactory@9b4ed7a
Mär 30, 2013 12:28:32 PM
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
registerHandlerMethod INFO: Mapped
"{[],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}"
onto public org.springframework.web.servlet.ModelAndView
com.landing.controller.CustomerController.add(javax.servlet.http.HttpServletRequest,org.springframework.ui.ModelMap)
Mär 30, 2013 12:28:32 PM
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
registerHandlerMethod INFO: Mapped
"{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}"
onto public java.lang.String
com.landing.controller.CustomerController.listAllFeedsOnIndexPage(org.springframework.ui.ModelMap)
throws com.google.appengine.labs.repackaged.org.json.JSONException Mär
30, 2013 12:28:32 PM org.springframework.web.servlet.DispatcherServlet
initServletBean INFO: FrameworkServlet 'mvc-dispatcher':
initialization completed in 520 ms Mär 30, 2013 12:28:32 PM
com.google.apphosting.utils.jetty.JettyLogger info INFO: Started
SelectChannelConnector@0.0.0.0:8888 Mär 30, 2013 12:28:32 PM
com.google.appengine.tools.development.AbstractServer startup INFO:
Server default is running at http://`localhost`:8888/ Mär 30, 2013
12:28:32 PM com.google.appengine.tools.development.AbstractServer
startup INFO: The admin console is running at
http://`localhost`:8888/_ah/admin Mär 30, 2013 1:28:32 PM
com.google.appengine.tools.development.DevAppServerImpl start INFO:
Dev App Server is now running null null null null null null Mär 30,
2013 1:28:39 PM
com.google.appengine.api.datastore.dev.LocalDatastoreService init
INFO: Local Datastore initialized: Type: High Replication Storage:
C:\Users\user\workspace\LandingPage\war\WEB-INF\appengine-generated\local_db.bin
Mär 30, 2013 1:28:39 PM
com.google.appengine.api.datastore.dev.LocalDatastoreService load
INFO: The backing store,
C:\Users\user\workspace\LandingPage\war\WEB-INF\appengine-generated\local_db.bin,
does not exist. It will be created. null null null null null null null
但是,当我在表单中按 Enter 时。我得到了一个数据条目和很多 null
条目。在我看来,重定向并没有重定向到其他页面,而是递归地重定向回来。
知道如何解决这个问题吗?
最佳答案
你可以尝试这样的事情。我正在成功发布表单后返回成功页面。
@RequestMapping(value="sendData" ,method = RequestMethod.POST)
public String add(HttpServletRequest request, ModelMap model) {
String firstName = request.getParameter("firstName");
String lastName = request.getParameter("lastName");
String email = request.getParameter("email");
System.out.println(email);
System.out.println(firstName);
System.out.println(lastName);
Customer c = new Customer();
c.setFirstName(firstName);
c.setLastName(lastName);
c.setEmail(email);
c.setDate(new Date());
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
pm.makePersistent(c);
} finally {
pm.close();
}
return "successpage";
}
关于java - 将 Servlet 重定向到 div 容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15718588/
我有一个关于 Java Servlet 的问题。 假设我在 servlet 网页“somePage”上。我想登录(使用另一个 servlet,“登录”servlet)。所以我点击“somePage”上
如何将变量数组从一个 servlet 传递到另一个 servlet? 最佳答案 如果您要将当前请求传递给另一个servlet,则只需将其设置为请求属性即可。 request.setAttribute(
什么可能导致此错误? Caused by: jakarta.servlet.UnavailableException: Servlet class org.restlet.ext.servle
我的maven依赖树是这样的 我想问我maven如何解决这个冲突,有两个servlet-api.jar?提前谢谢你。 最佳答案 如果您想从 Velocity 工具中删除 servlet-api,您可以
config ProcessReg ProcessReg text HelloWorld1 public class config implements Serv
您好,我有一个关于 servlet 调用另一个 servlet 的问题 我有一个名为 Relay 的主 servlet,它将负责控制其他 servlet 用户将点击并将转发到 Relay servle
在我的 REST API 项目中,我已将 /* 映射到 RESTServlet,并且需要在同一 WAR 中托管静态内容。我更愿意将 /static/* 映射到 WAS liberty 提供的默认 se
响应映射在 Servlet 中如何工作? 每个响应如何知道清除特定 HTML 或 Handlebars 上的输出? 最佳答案 有一个 ember-java带有 Jersey REST 服务 的 git
有一个 @WebServlet(urlPatterns = "/myServlet/") .如果用户转到 myapp/myServlet/other ,我仍然希望我的 servlet 能够捕获。也就是
我正在使用 Filter 在我的所有页面中插入反点击劫持 header - 这工作正常,除了 JBoss EAP 6.3 容器管理的登录页面,这是更重要的页面之一拥有它。 登录页面根本不调用过滤器,登
我正在尝试使用 RequestDispatcher 将数据从一个 servlet 传递到另一个 servlet。这是我的调度程序代码。 String address; address = "/Java
我刚刚开始使用 Servlet,并设法让一些 Servlet 充当单独的 URL,用于填充数据库以进行一些虚拟测试。某种形式: public class Populate_ServletName ex
我是否需要同时配置app.servlet.version 和 grails.servlet.version? 前者在application.properties中,后者在BuildConfig.gro
在Myeclipse中我创建了一个名为web1的Web项目,并添加了一个名为servlet1的servlet,web.xml如下: servlet1 servlet1
这个问题在这里已经有了答案: How to run a background task in a servlet based web application? (5 个回答) 6年前关闭。 是否可以在
在我的 ManagedBean 中,如果我将范围从 @RequestScoped 更改为 @ViewScoped,我将收到以下错误堆栈。我该如何解决这个问题?不过,当我运行应用程序时,我可以在页面中看
这个问题已经有答案了: How do I execute multiple servlets in sequence? (2 个回答) 已关闭 3 年前。 我已经构建了jdbc-Servlet的代码,
我一直在徒劳地尝试实现 tomcat 9 的 jakarta servlet,而不是以前的 javax.servlet 实现(因为我的理解是 jakarta 包是前进的方向)。问题是,当我将浏览器指向
我是 Spring 新手,正在尝试使用 Maven 部署和运行我的第一个 Spring Web 应用程序。有关更多详细信息,请参阅 here (我昨天发布的一个问题): 现在,我遇到的问题是:当我尝试
我正在尝试学习如何使用 JSP。我遇到了一些毫无意义的事情,至少在我看来是这样: 当我尝试运行时: response.getWriter().println(m.getDb().printAll())
我是一名优秀的程序员,十分优秀!