Some problems with new @Controller file
Posted: Wed Apr 25, 2012 4:05 am
Sorry but I mistaken with the post....it must be in Getting Started forum
Good morning,
I have installed the project with the instructions of "Getting Started", I switched the database to a postgreSQL and changed some things for the look and feel.
The problem is that I am trying to make a new jsp page (I am really rookie in Spring) and it does not work. That is I did:
-Create a new Controller class in the package of CheckoutController.java at the project "site"
-Add to the applicationContext-servlet.xml this lines in "site-war" project (aboutUsController is my @Controller ):
-This is the code of AboutUsController (to test I used the current cart page):
In my jsp I write this:
The first problem I had is that the ant task said to me that "it cant find the class file". I looked for it in the war file that I generated with ant and I didnt see it, I looked for it in the project "site-war" and I didnt see it.....I dont know why the java files arent in "site war" project, I found it in my "site" project
I copied it to resolve the problem (I hope you can say me what is my problem with that) and it works....but when I "clicked" in the link <a href="<c:url value="/aboutUs" />"> the message was :
HTTP ERROR 404
Problem accessing /mycompany/aboutUs. Reason:
NOT_FOUND
I hope you can help me , sorry for the huge post.... I think it would be better that you have all the information.
Best Regards
David
Good morning,
I have installed the project with the instructions of "Getting Started", I switched the database to a postgreSQL and changed some things for the look and feel.
The problem is that I am trying to make a new jsp page (I am really rookie in Spring) and it does not work. That is I did:
-Create a new Controller class in the package of CheckoutController.java at the project "site"
-Add to the applicationContext-servlet.xml this lines in "site-war" project (aboutUsController is my @Controller ):
Code: Select all
<context:component-scan base-package="org.broadleafcommerce">
<context:include-filter type="regex" expression=".*web.*"/>
<context:exclude-filter type="regex" expression=".*"/>
</context:component-scan>
<bean id="aboutUsController" class="com.webtiser.web.controller.AboutUsController">
</bean>
<property name="mappings">
<props>
<prop key="/store">catalogController</prop>
<prop key="/basket/**">blCartController</prop>
<prop key="/registerCustomer/*">blRegisterCustomerController</prop>
<prop key="/checkout/*">mycompanyCheckoutController</prop>
<prop key="/aboutUs/*">aboutUsController</prop>
</props>
</property>
-This is the code of AboutUsController (to test I used the current cart page):
Code: Select all
@Controller("aboutUsController")
@RequestMapping("/aboutUs")
public class AboutUsController {
@RequestMapping(method = RequestMethod.GET)
public String checkout(@ModelAttribute CheckoutForm checkoutForm,
BindingResult errors,
ModelMap model,
HttpServletRequest request) {
return "redirect:/basket/currentCart.htm";
}
@RequestMapping(method = RequestMethod.POST)
public String aboutUs(@ModelAttribute CheckoutForm checkoutForm,
BindingResult errors,
ModelMap model,
HttpServletRequest request) {
return "redirect:/basket/currentCart.htm";
}
In my jsp I write this:
Code: Select all
<a href="<c:url value="/aboutUs" />">
The first problem I had is that the ant task said to me that "it cant find the class file". I looked for it in the war file that I generated with ant and I didnt see it, I looked for it in the project "site-war" and I didnt see it.....I dont know why the java files arent in "site war" project, I found it in my "site" project
I copied it to resolve the problem (I hope you can say me what is my problem with that) and it works....but when I "clicked" in the link <a href="<c:url value="/aboutUs" />"> the message was :
HTTP ERROR 404
Problem accessing /mycompany/aboutUs. Reason:
NOT_FOUND
I hope you can help me , sorry for the huge post.... I think it would be better that you have all the information.
Best Regards
David