redirect - How to fix my url in spring framework -
i working spring mvc3.2 , have registration form(http://my-server.com:8080/tracks/apks). users post server , server return error message when validation fails. got error message server, url different wanted. here code:
web.xml <servlet-mapping> <servlet-name>tracks</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> applicationcontext.xml <bean id="viewresolver" class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix"> <value>/web-inf/pages/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean> @controller @requestmapping("/apks") public class apkcontroller { @requestmapping() public modelandview index() { map<string, object> modelmap = new hashmap<string, object>(); modelmap.put("menus", adminservice.getmenus("apks")); return new modelandview("apks", "model", modelmap); } @requestmapping(value = "/insert", method = requestmethod.post) public modelandview uploadapk(apkinfo apkinfo, bindingresult bindingresult) { map<string, object> modelmap = new hashmap<string, object>(); modelmap.put("menus", adminservice.getmenus("apks")); if (!fileexists(apk.getfilename())){ modelmap.put("message", message); } //do return new modelandview("apks", "model", modelmap); }
after calling uploadapk, expected http://my-server.com:8080/tracks/apks returned url http://my-server.com:8080/tracks/apks/insert.
what do fix it?
thanks in advance.
couple of observation.
- in web.xml, specify context-paran, servlet tracks , listener?
- is context:component-scan enabled in spring configuration file?
- use requestmapping @ method level map request specific method.
Comments
Post a Comment