<servlet>
<!-- 前端控制器 -->
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 配置文件路径 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/spring-*.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
上面是servlet的配置
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
上面是springMVC的视图解析器
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userServiceImpl;
/**
* 登录功能
*/
@RequestMapping("/isLogin")
public String isLogin(User userData,HttpSession session) {
User user = null;
user = userServiceImpl.queryByUserName(userData.getUserName());
if(user == null) {
session.setAttribute("false", "用户名或密码错误");
//return "redirect:/user/isLogin";
}
return "index";
}
}
这是controller,这是我做的登录功能,我想在后端跳转,因为其它页面都在WEB-INF中
var username = $("input[name='userName']").val();
var password = $("input[name='passWord']").val();
$.ajax({
type:"POST",
url:"user/isLogin",
data:{"userName":username,"passWord":password}
});
这是jsp页面,我用的ajax传输数据
但是登录成功后不跳转页面 ,求各位大牛帮一下忙,在此谢过各位了