This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Unable to Render Form View

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to Spring and learning Usage of Form using SimpleFormController Class

public class LoginController extends SimpleFormController {

LoginService loginService;

public LoginService getLoginService() {
return loginService;
}

public void setLoginService(LoginService loginService) {
this.loginService = loginService;
}

String formView;
String successView;

public LoginController() {

setCommandClass(Login.class);
setCommandName("login");
setFormView("Login");
System.out.println("In Contructor");
}

protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response, Object command, BindException errors) {

Login loginVO = (Login) command;
System.out.println("User Name" + loginVO.getUserName());
System.out.println("User Name" + loginVO.getPassWord());
return new ModelAndView("success", "user", loginVO);
}


My Dispatcher-Servlet.xml
----------------------------------
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />

<bean id="LoginService" class="com.LoginService" />

<bean name="/Login.jsp" class="com.LoginController"
p:loginService-ref="LoginService" p:formView="Login" p:successView="success" />
Web.xml
-----------
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>Welcome.html</welcome-file>
</welcome-file-list>


MY Welcome Page is welcome.html ,Tomcat id not displaying Error Message,But iam not able to display FormView ie login.jsp.

Tomcat Console
----------------
Dispatcher Initialized
Loading Bean Definitions
Mapped URL path [/Login.jsp] onto handler [com.LoginController
Reloading Context with name [/SimpleFormController] is completed
 
Ranch Hand
Posts: 56
4
Mac OS X IntelliJ IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<bean name="/Login.jsp" class="com.LoginController"
p:loginService-ref="LoginService" p:formView="Login" p:successView="success" />

that doesn't look the way it should be.

You have two options - either you start with a Controller (java class, which you map from a certain relative url path to your Controller,
or you call a certain jsp, which gets rendered, and when the user hits a submit button, you forward the request to a Controller like in this case
your LoginController. You mixed it up, I don't feel you really understand how the incoming request is handled to and from the server -
Try to understand this first, before you try setting up your application.

Hope that helps.

 
deepu bhadriraju
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you mean i need to write two controller class (one for Displaying the form using AbstractController ,two for formsubmission),Can you please correct the mistake i have done in the code
 
crispy bacon. crispy tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!