Problem Description : front-end can be accessed through the address controller layer , the control layer can not return jsp page, not an error
spring3mvc-servlet.xml configuration is as follows
<!-- 添加注解驱动 -->
<mvc:annotation-driven />
<!-- 使Spring支持自动检测组件,如注解的Controller 这里只能扫描controller包如果扫描了service包 则事务会失效 -->
<context:component-scan base-package="china.home.daughter.*.*.controller*"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />
web.xml configuration
<!-- spring mvc 配置 -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/spring/spring3mvc-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
control layer code :
@RequestMapping(value = "/login.html", method = RequestMethod.GET)
public String login(HttpServletRequest request, HttpServletResponse response, User user) {
User user2 = userService.getUserByUserNamePassword(user.getUsername(), user.getPassword());
if (null != user2) {
User user3 = new User();
user3.setUsername(CommonUtil.getUUID());
user3.setPassword("");
// 保存方法
userService.saveUser(user3);
// 更新用户
user2.setRealName("JeffreyJi");
userService.updateUser(user2);
// 获取user
logger.info(CommonUtil.isNull(userService.getUserById(user2.getId())) + "");
}
if (null != user2) {
logger.info(user2.toString());
request.getSession().setAttribute("user", user2);
} else {
}
logger.info("请求成功!");
return "main1/main1";///WEB-INF/jsp/ 下有文件夹main1 下面有 main1.jsp
}
------ Solution ------------------------------------- -------
This not dubbed *. html, changed /
------ Solution ------------------------- -------------------
spring-servlet.xml years plus
viewResolver bean to try
------ Solution ------------------------------------ --------
deliberately tried your configuration , the configuration you provide is no problem , if you still can not find the words of the page , or check your configuration file path , the path is correct jsp files
------ Solution ---------------------------------------- ----
put / WEB-INF/jsp
replaced
/ WEB-INF/page it
my program , I do not remember a spring or upgrade after upgrade tomcat , the former does not take a path on the life and death of ......
------ For reference only -------- -------------------------------
way upstairs to try it? url has changed the way the request .
------ For reference only -------------------------------------- -
not, or can not access .
------ For reference only -------------------------------------- -
report anything wrong with it ?
------ For reference only -------------------------------------- -
that way or not, before modification, I write directly to the address in the address bar is accessible .
------ For reference only -------------------------------------- -
what's wrong is not reported , and certainly the method of executing the controller
------ For reference only -------------------- -------------------
I also studied springMVC these days you this return value does it return values but also with how it return path ; "main1/main1" ;/ / / WEB-INF/jsp / folder under main1 below main1.jsp you want to return to it this main1 directory you add to the prefix ah p: prefix = "/ WEB-INF/jsp/main1" then return "main1" you should be able to try
------ For reference only --------------------------- ------------
main1/main1 that this has no corresponding jsp page.
------ For reference only -------------------------------------- -
to do with this matter, I was directly in the address bar http://localhost:8888/daughter/userLogin/login.html?username=admin&password=admin this is accessible !
------ For reference only -------------------------------------- -
does not work, I write the address directly in the address bar is no problem
------ For reference only ------------------ ---------------------
jsp path should go wrong , I write directly in the address bar to access
- ----- For reference only ---------------------------------------
jsp path should go wrong , I write directly in the address bar to access
jsp can access the address directly under WEB-INF it?
------ For reference only -------------------------------------- -
jsp path should go wrong , I write directly in the address bar to access
jsp can access the address directly under WEB-INF it?
http://localhost:8888/daughter/userLogin/login.html?username=admin&password=admin this is the address
------ For reference only ---- -----------------------------------
control layer can not return jsp page, not an error
refers to the return of the 404 pages are still blank jsp page ?
------ For reference only -------------------------------------- -
I made a landing page

After clicking submit , still to this page. I am using a jquery easyui front
suspected cause of the problem is : the way easyui submission is also submitted to the official website of asynchronous read mode according to the official website to submit written
but I still can not.
$('#ff').form('submit',{
url:'userLogin/login.html',
onSubmit:function(){
return $(this).form('validate');
},
success:function(){
alert("1234");
}
});
------ For reference only -------------------------------------- -
I made a landing page

After clicking submit , still to this page. I am using a jquery easyui front
suspected cause of the problem is : the way easyui submission is also submitted to the official website of asynchronous read mode according to the official website to submit written
but I still can not.
$('#ff').form('submit',{
url:'userLogin/login.html',
onSubmit:function(){
return $(this).form('validate');
},
success:function(){
alert("1234");
}
});
problem it is presented in a way that your form and action are to be submitted post try method = RequestMethod.POST
------ For reference only ------ the reason ---------------------------------
you can access directly address is the way you address access that get presented in a way , and you form submission is
------ For reference only POST submitted ------------------------- --------------
I made a landing page

After clicking submit , still to this page. I am using a jquery easyui front
suspected cause of the problem is : the way easyui submission is also submitted to the official website of asynchronous read mode according to the official website to submit written
but I still can not.
$('#ff').form('submit',{
url:'userLogin/login.html',
onSubmit:function(){
return $(this).form('validate');
},
success:function(){
alert("1234");
}
});
problem it is presented in a way that your form and action are to be submitted post try method = RequestMethod.POST
discovered the problem, not the POST problem , I use jquery:. $ ('# ff') submit () can be submitted to jump with easyui itself will not do, do not know why. ? also used easyui never before found such a problem
------ For reference only -------------------------- -------------
I made a landing page

After clicking submit , still to this page. I am using a jquery easyui front
suspected cause of the problem is : the way easyui submission is also submitted to the official website of asynchronous read mode according to the official website to submit written
but I still can not.
$('#ff').form('submit',{
url:'userLogin/login.html',
onSubmit:function(){
return $(this).form('validate');
},
success:function(){
alert("1234");
}
});
problem it is presented in a way that your form and action are to be submitted post try method = RequestMethod.POST
discovered the problem, not the POST problem , I use jquery:. $ ('# ff') submit () can be submitted to jump with easyui itself will not do, do not know why. ? also used easyui never before found such a problem
it should be because different versions of jquery , I used easyui1.3.2 version , correspond jquery 1.8 , presented in a way that you used before that
$ ('# ff'). form ('submit', {
url: 'userLogin / login.html',
onSubmit: function () { .
return $ (this) form ('validate');
},
success: function () {
alert ("1234");
}
});
------ For reference only ----------------------- ----------------
I made a landing page

After clicking submit , still to this page. I am using a jquery easyui front
suspected cause of the problem is : the way easyui submission is also submitted to the official website of asynchronous read mode according to the official website to submit written
but I still can not.
$('#ff').form('submit',{
url:'userLogin/login.html',
onSubmit:function(){
return $(this).form('validate');
},
success:function(){
alert("1234");
}
});
problem it is presented in a way that your form and action are to be submitted post try method = RequestMethod.POST
discovered the problem, not the POST problem , I use jquery:. $ ('# ff') submit () can be submitted to jump with easyui itself will not do, do not know why. ? also used easyui never before found such a problem
it should be because different versions of jquery , I used easyui1.3.2 version , correspond jquery 1.8 , presented in a way that you used before that
$ ('# ff'). form ('submit', {
url: 'userLogin / login.html',
onSubmit: function () { .
return $ (this) form ('validate');
},
success: function () {
alert ("1234");
}
}); not a version of the problem , I quoted version 1.3.2 or not.
------ For reference only -------------------------------------- -
main1/main1 modified to / main1/main1 try.
------ For reference only -------------------------------------- -
find a reason, because easyui the form submission is asynchronous so you can not jump. Thank you for your suggestion
没有评论:
发表评论