我有一个提交表单的jsp。
<form name="loginForm" id="loginForm" action="j_spring_login" method="post" class="login-form">
<div class="login-inputTxt"><input type="text" class="form-control" id="username" placeholder="User Name" required autofocus value=""/></div>
<!--<small class="help-block" id="username-error-msg" style="display: none;"></small>-->
<div class="login-inputTxt"><input type="password" class="form-control" id="password" placeholder="Password" required value=""/></div>
<!--<small class="help-block" id="password-error-msg" style="display: none;"></small>-->
<div class="login-inputTxt">
<select name="languagesel" id="languagesel" class="form-control" onChange="FnSelectLanguage(this.value)">
<option value="english" selected> English</option>
<option value="arabic"> اÙعربÙØ©</option>
</select>
</div>
<div class="clearfix"></div>
<div class="form-group text-center">
<input type="submit" value="TEST">
<!-- <a href="Javascript:void(0)" class="btn btn-default btn-block lngsigninhead" id="loginFormButton" onclick="FnLogin()">Sign In</a> -->
</div>
<span class="progress-bar text-right pull-right" id="progress-bar-login" style="display: none;"></span>
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
<!-- <div class="checkbox"><label style="font-size: 12px; color: #e8c31c; text-transform: initial;">Forgot Password?</label></div> -->
</form>
在我的applicationContext中我有
<context:component-scan base-package="com.smart.city.*"></context:component-scan>
<mvc:default-servlet-handler />
<!-- <mvc:annotation-driven /> -->
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="resources/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
我有一个控制器
@Controller
public class LoginController {
@RequestMapping(value ="j_spring_login",method = RequestMethod.POST)
public ModelAndView maintainUserSession(HttpServletRequest request) {
System.out.println("::::::::::: in maintainUserSession :::::::::" + request.getParameter("username"));
System.out.println("::::::::::: in maintainUserSession :::::::::" + request.getParameter("password"));
}
}
这是我的web.xml - servlet映射
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
我的问题是如果我使用<mvc:default-servlet-handler />
我的jsp正在加载所有静态css,js&amp;图像,但它不会将请求转发给我的控制器,反之亦然
请协助
答案 0 :(得分:0)
尝试将前缀值更改为/ resources / jsp。我希望问题得到解决