Your SlideShare is downloading. ×
Simple blog wall creation on Java
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Simple blog wall creation on Java

602
views

Published on

Published in: Self Improvement

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
602
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Ja basva ed
  • 2. JAVASPRING-CORESPRING SECURITYJSPMYSQLTOMCATJUNIT
  • 3. JDK 7IDEMySQL 5Tomcat 7Maven 3
  • 4. 1 run mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DarchetypeVersion=1.0 -DgroupId=blog-wall -DartifactId=blog-wall -Dversion=1.0-SNAPSHOT2 configure spring core and spring security
  • 5. -Install MySQL-Make project-Build war-Deploy
  • 6. Development process• configs• Java classes• jsp
  • 7. applicationContext-security.xml• <authentication-manager>• <authentication-provider>• <jdbc-user-service data-source-ref="dataSource"• users-by-username-query="• select username,password, enabled• from users where username=?"• authorities-by-username-query="• select u.username, ur.authority from users u, user_roles ur• where u.user_id = ur.user_id and u.username =? "• />• <password-encoder ref="encoder"/>• </authentication-provider>• </authentication-manager>
  • 8. blog-wall-servlet.xml• <context:component-scan base-package="com.makstitoff.blogwall"/>• <context:annotation-config/>• <tx:annotation-driven transaction-manager="transactionManager"/>• <bean id="entityManagerFactory"• class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">• <property name="dataSource" ref="dataSource"/>• <property name="jpaVendorAdapter">• <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">• <property name="generateDdl" value="true"/>• <property name="database" value="MYSQL"/>• <property name="showSql" value="true"/>• </bean>• </property>• <property name="persistenceUnitName" value="jpa.sample"/>• </bean>
  • 9. RegistrationController• @Controller• public class RegistrationController {• @Autowired• private UserService userService;• @RequestMapping(value = "/register", method = RequestMethod.POST)• public String createNewUser(final @RequestParam(value = "login", required = true) String login, final @RequestParam(value = "password", required = true) String password) {• userService.createNewUser(login, password);• return "redirect:/index.jsp";• }• }
  • 10. PostController• @Controller• public class PostController {• @Autowired• private PostService postService;• @RequestMapping(value = "/getAllPosts", method = RequestMethod.POST)• public ModelAndView getAllPosts() {• List<Post> posts = postService.getAll();• return new ModelAndView("posts", "posts", posts);• }• @RequestMapping(value = "/post", method = RequestMethod.POST)• public String post(@RequestParam(value = "text", required = true) String text) {• if (text.length() > 1024) {• text = text.substring(0, 1024);• }• postService.post(text);• return "redirect:/index.jsp";• }