-
May 24th, 2011, 11:51 AM
#1
convert from struts to spring3
When I convert from struts to spring, can I still use *.do instead *.htm in web.xml file?
<servlet-mapping>
<servlet-name>spring_mvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
-Henry
-
May 24th, 2011, 12:19 PM
#2
You can use what ever the extension that is appropriate for your application
Servlet Container inteprets the following line as : All the requests with this extension will be handled by servlet with name spring_mvc servlet
<servlet-name>spring_mvc</servlet-name>
<url-pattern>*.do</url-pattern>
I am guessing you are mapping spring_mvs to (DispatcherServlet, which acts as FrontController and a Dispatcher)
-- Prasanna Talakani
Blog
-
May 24th, 2011, 12:41 PM
#3
Thank you for your info. But when I have the following code:
@Controller
public class Yp_search extends ActionBase_pub
{
static Log log = LogFactory.getLog("mcores.Yp_search");
@RequestMapping(value = {"/yp_search.do}, method = RequestMethod.GET)
protected ModelAndView yp_search(ModelAndView mv,
HttpServletRequest request) throws Exception
{
AppForm theForm = new AppForm();
mv.getModel().put("appForm", theForm);
mv.setViewName("yp_search");
HttpSession session = request.getSession();
try
{
...
} catch (Exception e)
{
...
}
log.debug("view_Yp_search-OK");
return mv;
}
}
and I tried: http://localhost:8080/yp_search.do and I got the following errors:
javax.servlet.ServletException: Could not resolve view with name 'yp_search'
in servlet with name 'spring_mvc'
javax.servlet.ServletException: Could not resolve view with name 'yp_search'
in servlet with name 'spring_mvc'
at org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:1042)
at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:798)
at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:716)
at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:549)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:114)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:91)
at com.caucho.server.dispatch.ServletFilterChain.doFi lter(ServletFilterChain.java:103)
at edu.umich.authentication.cosign.filter.CosignAuthe nticationFilter.doFilter(CosignAuthenticationFilte r.java:62)
at com.caucho.server.dispatch.FilterFilterChain.doFil ter(FilterFilterChain.java:87)
at com.caucho.server.webapp.WebAppFilterChain.doFilte r(WebAppFilterChain.java:187)
at com.caucho.server.dispatch.ServletInvocation.servi ce(ServletInvocation.java:265)
at com.caucho.server.http.HttpRequest.handleRequest(H ttpRequest.java:273)
at com.caucho.server.port.TcpConnection.run(TcpConnec tion.java:682)
at com.caucho.util.ThreadPool$Item.runTasks(ThreadPoo l.java:743)
at com.caucho.util.ThreadPool$Item.run(ThreadPool.jav a:662)
at java.lang.Thread.run(Thread.java:619)
Same code worked with *.htm
-Henry
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules